display string in PHP with preg_match


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>

NB: The words cn be changed in the string, how can I use something like pregmacthe...




Assuming you forgot a in your string:

$str = 'lowLow Resolution jpeghighHigh Resolution jpegepsEps';
foreach(array_chunk(explode('', $str), 2) as $chunk) {
    echo '<li>'.$chunk[0].'</li><span>'.$chunk[1]."</span>\n";

People are also looking for solutions to the problem: timezone - PHP: Get Time for Current Region


Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.