Explanation for PHP preg_match_all matches array print_r

Solution:
try this so easy to make that
<?php
//$re = "/^(-\\w+\\s*.*)\\n*$/um";
$re = "/^(\\h*(?:-|&)\\h*\w+\\s*.*)\\n*$/um";
$str = "-Give on result\n-Second new text\n-The third text\n\nAnother paragraph without list.\n\n-New list here";
preg_match_all($re, $str, $matches);
echo "<pre>";
print_r($matches);
echo "</pre>";
$i = 0;
echo "<ul>".preg_replace_callback($re,function($mt){return "<li>".$mt[1]."</li>";},$str)."</ul>";
$re = array_filter(preg_split('/\n/', $str));
echo "<pre>";
print_r($re);
echo "</pre>";
Answer
Solution:
I'm trying to replicate this. I usually use this tool https://www.debuggex.com/r/AXpFXcR-ioMLhLCd that explains the Regex conditions in a fancier way.
So far, I think the code evals the regex and only one\n
is catched, so the next one passes directly to the output. But I'm trying to confirm this behavior.
Share solution ↓
Additional Information:
Link To Answer People are also looking for solutions of the problem: failed to create image decoder with message 'unimplemented'
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.
Similar questions
Find the answer in similar questions on our website.
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.