Forum Moderators: coopster
I can already isolate what's inside the square bracket tags so i can format them as i wish.
for example: php tag is color coded, i apply htmlentities to html tags, tips tag has a yellowish background
but now i need to select whats NOT inside the tags so i can apply nl2br so line breaks can be displayed on the browser.
i cant just apply nl2br to the whole string because then i would get double spacing on the color coded php or on htmlentities
is there a regular expression on preg_split or someway i can just get the parts that is not surrounded by the bbcode tags?
$text = '[B]Hello[/B] This is a
line [U]break[/U]';
$array = preg_split('/\[.+\]/', $text, -1, PREG_SPLIT_DELIM_CAPTURE);
/* I didn't test, but this is my guess:
$array =
Array
{
[0] =>
[1] => [B]
[2] => Hello
[3] => [/B]
[4] => This is a
line
[5] => [U]
[6] => break
[7] => [/U]
[8] =>
*/