I am making a website, and I would like to make a custom Markup type language in PHP. I want the tags to be surrounded with [
and ]
. Now, I was thinking about this, like anyone would, and I could do something like this:
function formatMarkup($markup = ''){
$markup = str_replace('[color=blue]', '<span style="color: blue">', $markup);
return $markup
}
Even though that might work, it would be more progrematically correct if it would do something like explode()
, but starting at every [
and ending at every ]
. This would be great if I found out. Thank you for your time and effort.
EDIT:
I have decided to use preg_split()
. It seems nice, and all, but I cannot get the regex. Here is my code.
EDIT #2: I have got most of the regex done, but there are uneeded extra keys in the array. How would I fix them? Here is my new code.