I got the following string:
low|Low Resolution jpeg high|High Resolution jpeg eps|Eps
I would like to display in like :
<li>low</li><span>Low Resolution jpeg</span>
<li>high</li><span>High Resolution jpeg</span>
<li>eps</li><span>eps</span>
NB: The words 开发者_运维百科cn be changed in the string, how can I use something like pregmacthe...
Assuming you forgot a |
in your string:
<?php
$str = 'low|Low Resolution jpeg|high|High Resolution jpeg|eps|Eps';
foreach(array_chunk(explode('|', $str), 2) as $chunk) {
echo '<li>'.$chunk[0].'</li><span>'.$chunk[1]."</span>\n";
}
?>
精彩评论