Answer the question
In order to leave comments, you need to log in
How to parse a list in PHP?
There is such a script that displays a list that is separated by a tag <br>
.
For example:
123
456
789
How to parse it into an array?
For example: ['123','456','789']
Answer the question
In order to leave comments, you need to log in
$str = '123<br>456<br/>789<br />0';
$arr = preg_split('/<br[^>]*>/i', $str);
// print_r($arr);
/*
Array
(
[0] => 123
[1] => 456
[2] => 789
[3] => 0
)
*/
Didn't find what you were looking for?
Ask your questionAsk a Question
731 491 924 answers to any question