I have problem with search in arrays , in 2 arrays , the first array have one structure fixed and the second send the vars from url and can have some values empty , for example
FIRST ARRAY :
The structure it's this :
id value , cat value , subcat value and country value
$ar_val="134567,dogs,food,EEUU";
The second var get from URL
$ar_url="134567,dogs,toys,EEUU";
As you can see in the second var , $ar_url i have one value no same to the first structure of $ar_val in this case toys
I want get compare the fixed structure of $ar_val and get if true or false if have same value in the same order from $ar_val
I try this :
$ar_val="134567,dogs,food,EEUU";
$ar_url="134567,dogs,toys,EEUU";
$exp_ar_val=explode(",",$ar_val);
$exp_ar_url=explode(",",$ar_url);
foreach ($exp_ar_val as $exp_ar_val2)
{
$ar_val_end[]=$exp_ar_val2;
}
foreach ($exp_ar_url as $exp_ar_url2)
{
$ar_val_end2[]=$exp_ar_url2;
}
$end_results=array_intersect($ar_val_end,$ar_val_end2);
With this I want know for example: If I search by id and for example for cat , get result positive in 2 arrays i have the same data , but if search for subcat i can´t get results because are differents in one have food and in other have toys , but with array_intersect no get this for compare
Thank´s , Regards
I think he wants to check if a value exists in either array. try this...