检查数组是否具有特定位置的值

I'm getting the index keys of a haystack array containing many needles. The array contains another words too, but I don't need them to be checked.

So I'm using array_keys($haystack, &needle); to create an array containing the position of each needle.

Now I need to check in another array if on the positions from the array I've obtained by using array_keys I have a specific value. I need some ideas about how to do this.

The main idea:

$check = array_keys($haystack, &needle);
*now I need to check if I have a value on the positions from $check on $array2*

Then I need to do an action if it is found on a position (it doesn't matter on what position).

You don't need to do array_keys();.

You can do it like this.

foreach ($haystack as $needle) {
  if ($needle == $your_value) {
   /* your stuff */
 }
}

It'll work with this if it's an associative:

foreach($array1 as $k => $v)
{
  if(isset($array2[$k]))
  {
    // Your thing
  }
}

If you want to find based on the exact key index:

for($i = 0; $i < count($array1); $i++)
{
  if($array1[$i] == "needle" && isset($array2[$i]))
  {
    if($array2[$i] == "goose")
    {
      // Your thing
    }
  }
}