To begin I have a multi-dimensional array as seen below:
$array=array (0 => array (0 => '',),1 => array (0 => 'sample.com',1 => 'test.com',2 => 'check.com',3 =>'rack.com',),2 => array (0 => '12345.34535',1 => '243.345345.4535',2 => '3453.534534',3 => '45.453453',),3 => array (0 => '978.797',1 => '789.7897997.7897',2 => '97897.78979.798',3 => '78978979',),4 => NULL,5 => NULL,6 => NULL,7 => NULL,8 => NULL,9 => NULL,10 => NULL,11 => NULL,12 => NULL,);
I have the options the user selected in a variable:
$options=array (0 => 'blreferrer',1 => 'ipwl',2 => 'ipbl',);
I use the below code to get the correct keys from the multidimensional array form the users selection
$options1 = array(0=>"wlreferrer",1=>"blreferrer",2=>"ipwl",3=>"ipbl",4=>"geowl",5=>"geobl",6=>"languagewl",7=>"languagebl",8=>"browserwl",9=>"browserbl",10=>"oswl",11=>"osbl",12=>"viscount");
$option2 = (array_intersect($options1, $options));
$option3 = (array_keys($option2));
The below code is utilized for searching the first multidimensional array
$option4 = array();
$referrer = 'sample.com';
$ip = '789.7897997.7897';
$option5 = array(0=>$referrer,1=>$referrer,2=>$ip,3=>$ip,4=>$geo,5=>$geo,6=>$language,7=>$language,8=>$browser,9=>$browser,10=>$os,11=>$os,12=>$viscount);
Finally I try and search
foreach ($option3 as $key) {
if (in_array($option5[$key], $array[$key])) {
array_push($option4, "0");
} else {
array_push($option4, "1");
}
}
When I print out $option4 I get the below results when it should be 0,1,0..
Array ( [0] => 1 [1] => 1 [2] => 1 )
I believe the problem stems from using in_array on a multi-dimensional array however haven't been able to find any solutions.