Reputation: 1161
I'm trying to turn this string:
> President Obama pointed blabla<br /> <br /> The only way I get this
> stuff <br /> <br /> I'm consulting with the Pentagon, with <br /> <br
> />
into this array: (new array element for each "<br /> <br />
")
array (
[0] => President Obama pointed blabla
[1] => The only way I get this stuff
[2] => I'm consulting with the Pentagon, with
);
I tried to use explode("<br /><br /> ", $string)
but it doesn't work. Any ideas?
Upvotes: 0
Views: 90
Reputation: 416
Unless it was a typo, you are missing a space in your explode() between each
. Alternatively you could do:
$br2arr = array_filter(preg_split("/([\s\b]*<br \/>[\s\b]*)|([\s\b]*<br>[\s\b]*)/", $str));
Which should do what you want in any case/format
Upvotes: 0
Reputation: 3932
In your case explode("<br /> <br />", $string);
would work.
More generally, you can add: $string = str_replace('<br /> <br />', '<br /><br />', $string);
before the previous line if you have some lines that are separated by <br /> <br />
and some by <br /><br />
Upvotes: 1
Reputation: 15706
Looks like you just need to remove the first two characters of each line ("> "), concatenate all the lines, then do your explode (noting the missing space, as others have pointed out).
Upvotes: 1
Reputation: 1868
Try adding a space between your <br />
tags in the explode
function.
Upvotes: 0