How can I get X (or another value) from this string "asdfsadf[www]X[/www]", basically i want to get what ever is in between the [www] tags and place them in a variable called $www , can anyone help?
You could probably use the strrpos($string, "[www]") to get the position of the "X" data. Then use the substr($string, $position_start, $position_end) function to create your $www variable...
Michael wrote: > How can I get X (or another value) from this string > "asdfsadf[www]X[/www]", > basically i want to get what ever is in between the [www] tags and > place them in a variable called $www , can anyone help?
Thanks, this looks like it will work fine, I don't have time to try it now but I will have a look at it later. I would be interested to know if there is a simpler way to do it though.
a less efficient, but perhaps easier to read or more flexible method would be something like: ereg('\[www\](.*)\[/www\]', $text, $arr); $variable_inside_www = $arr[1];
Michael wrote: > I need a solution that will loop until all of the [www][/www] tags in > string into an array and from there on i have everything sorted.
If you want to go the regular expression way, have a look at preg_match_all().
If you want to go the strpos(), substr() way, remember the third parameter to the strpos() function.