user2881809
user2881809

Reputation:

Split a string by <br> tags wrapped in newlines

We have rows:

1 test1
<br> 
2 test2
<br> 
3 test3
<br> 
4 test4

For explode in array we test next:

$ArrText = explode("\n",$text);
$ArrText = explode("<br>",$text);

But it not worked.

Tell me please how to split a string into array elements ?

Upvotes: 0

Views: 71

Answers (1)

John Conde
John Conde

Reputation: 219804

$ArrText = explode("\n<br>\n",$text);

Two things:

  1. You have to split by a new line followed by a <br> followed by a new line
  2. Escape characters only work in double quotes, not single ones.

Upvotes: 5

Related Questions