Hi
I have a str say
$str = "My name is %john% and I live in a house. My freind is called %sarah" and she lives in another house";
I need search the string to find all words which are surrounded by the % and stick them in an array if possible.
Does anyone know how to do this?
Thanks in advance
j
try:
$str = "My name is %john% and I live in a house. My freind is called %sarah% and she lives in another house";
preg_match_all( "/%(\w+)%/", $str, $m );
while( list( $key, $val ) = each( $m[1] )) { print "$key => $val<br>\n"; }
hth stew