i have the following code that matches a variable with a string
Code: Select all
$search_data = array("2","4","51");
foreach($search_data as $value){
$pattern = "/\"".$value."\"/";
$do = preg_match_all($pattern, $post2, $matches);
if($do){
foreach($matches[0] as $value){
$arr_matches[] = $value;
}
}else{
$arr_matches[] = "00";
}
}i know it is possible to specify the order that items must match but how can i achieve this with the method i am using above? or is there a better way of doing this? Because i need to make sure that the values don't just match but match in the same order as they occur in search_data. NB when i say same order i mean that other values can come in between
for example if search_data = 1,2 and 3 and was compared with the following strings...
STRING1 - 1,2,3
would be just as good as
STRING2 - 1,5,2,8,9,3
is that possible in one statement or would i need multiple preg_match statements
cheers for your help
rj