H
H
HelpMePlease22020-04-25 11:51:52
PHP
HelpMePlease2, 2020-04-25 11:51:52

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

1 answer(s)
R
Roman Sarvarov, 2020-04-25
@HelpMePlease2

$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 question

Ask a Question

731 491 924 answers to any question