i have array of strings
$x=array("hello","how","you","iam","fine") i tried extract 1 string pattern this
$y=preg_grep ("/hello(\w+)/", $x); print_r($y); i want have multiple pattern search , return using 1 preg_grep can me over.
regex quantifier + means match 1 or more times. string hello doesn't fits, 'cause there're 0 symbols after hello. use * quantifier means match 0 or more times:
$x=array("hello","how","you","iam","fine"); $y=preg_grep ("/hello(\w*)/", $x); print_r($y); // outputs: array ( [0] => hello )
Comments
Post a Comment