I need a simple markup language to store different parts of a string on a TEXT field, and then extract those parts. So basically I want some kind of simple XML. Storing those in the table field is easy, but extracting them... is other matter. I managed to do so using a simple regex done for regular HTML:
|<[^>]+>(.*)</[^>]+>|U
But in order to re-compose the original array (and use the markup more generally) I need also to know the tag names. And that regex does't do that.
Examples:
Input text:
<user_input>Hello! my name is Williams</user_input>
The preg_match_all() function using the above regex returns:
array
0 =>
array
0 => string '<user_input>Hello! my name is Williams</user_input>' (length=34)
1 =>
array
0 => string 'Hello! my name is Williams' (length=34)
I need it to return the "user_input" name of the tag. Yes, I know, I suck on regex. Yes, I know "use a XML parser", but that is too big for what I'am doing.