Monday, April 30, 2012

extract 9 digit number from a string

I basically have an array in php which contains a string, I basically need to filter the string in order to get a 9 digit ID number (which is surrounded by brackets), im sure there could be a way to do this with regex but im clueless.



I know that regex returns its results as an array as there could be multiple results but I know that there will not be multiple results for each string and therefore I need to put the result straight in to my already existing array if possible



example:



function getTasks(){
//filter string before inserting into array
$str['task'] = "meeting mike (298124190)";

return $str;
}




No comments:

Post a Comment