Let me know if that doesn't help.
also, check these pages out :)
http://us2.php.net/manual/en/function.substr.php
http://us2.php.net/manual/en/function.strrpos.php
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.
while (ereg('\[www\](.*)\[/www\](.*)', $text, $arr))
{
$variables_inside_www[] = $arr[1];
$text = $arr[2];
}