Hello all, i have two arrays i.e
$ar1=array("Mobile","shop","software","hardware");
and
$arr2=arry("shop","Mobile","shop","software","shop")
i want to compare the elements of arr2 to arr1 i.e
foreach($arr2 as $val)
{
if(in_array($val, $arr1))
{
//mycode to insert data into mysql table
variable++; // here there should be a variable that must be increamented when ever match found in $arr2 so that it can be saved into another table.
}
$query="update table set shop='$variable',Mobile='$variable'.......";
}
my problem is when ever a match is found in if(in_array($val, $arr1) my code will be executed. here i want a variable or an array to count how many times that matched item/element is found i.e for shop=3 and for mobile and software it should be 1. Later in my update query i want to set the fields with this count