Thursday, 12 September 2013

preg_grep returning whole string instead of part

preg_grep returning whole string instead of part

the following code is run
$mysqlquery = "SELECT `description` FROM `table`";
$sqlresourceid = mysql_query($mysqlquery);
$subject = mysql_fetch_row($sqlresourceid);
$regexisbn = '/(97(8|9))?\d{9}(\d|X)/i';
$pattern = '/.*/i';
$matches = preg_grep ($regexisbn, $subject);
var_dump($matches);
however this returns the following
ISBN10: 0470945176 by Paul D. Kimmel Publisher: John Wiley & Sons
Copyright year: © 2011
I just wanted it to return the ISBN 0470945176 , how come this is happening?

No comments:

Post a Comment