Q:

How can I Check the current value which is already passed or not in an array in nested foreach in php

My array 
$key1=>
Array
(
    [0] => 1
    [1] => 2
    [2] => 7
    [3] => 11
    [4] => 12
    [5] => 17
    [6] => 18
)

$_POST['name']=>
Array
(
    [0] => General
    [1] => General
    [2] => Outdoors
    [3] => Dining
    [4] => Kitchen

)

Here is my code,
       foreach ($key1 as $key => $value) {
        // echo $value;
              foreach ($_POST['name'] as $key => $value1) {
                    //echo $value;
                    $subQueryCond .=' AND '.$value1.' LIKE  ' .$value ;
                         }
        }

While my Ajax calls this nested loop occurs..
Inside this I wrote a query..
If one value is passed.
The query is in the format of  AND 'General' LIKE 1.  
And if another value is passed in the $key1 it pass the query two times. 
It's like How many arrays are given that much time that query was passed..
So,here I would like to restrict the $value if it already came..
if two values were given,it pass the query in the following manner
AND General LIKE  1 

AND Outdoors LIKE  1 

AND General LIKE  7 

AND Outdoors LIKE  7

And my desired query must be in the form of
AND General LIKE  1 

AND General LIKE  7 

AND Outdoors LIKE  7

can someone help me..

A:

This will work for you... 
<?php 

$subQueryCond= '';
foreach ($key1 as $key => $value)
{
  foreach ($_POST['name'] as $key => $value1) 
  {
     $subQueryCond['AND '.$value1.' LIKE  ' .$value] = ' AND '.$value1.' LIKE  ' .$value ;
  }
}
echo "<pre>"; print_r($subQueryCond);
$query =  implode('',$subQueryCond) ;
print_r($query);

?>

just make an array with unique keys to value, then use implode() function to make query string...

