检查数组中是否存在值

I want to check if product exist in wishlist array, so I can make a function to get id of products in wishlist and the result is

Array
    (
    [0] => Array
        (
            [product_id] => 28
        )

    [1] => Array
        (
            [product_id] => 30
        )

    [2] => Array
        (
            [product_id] => 42
        )
    )

my code is

foreach ($products as $product)
 show products in this style else in this style

I want to check if

$product['product_id'] = the product id in $wishids array

You can use in_array with array_column, see example below:

if(in_array($productID, array_column($wishids, 'product_id'))
  echo 'Match found';
else 
  echo 'Match not found';

Ofcourse. You can do it using in_array() function of php. You can refer it here.

http://www.w3schools.com/php/func_array_in_array.asp

All You need to do is to call this function in a loop traversing through $products and pass the id into the function. You will get your result accordingly.

use in_array

foreach ($products as $product)
{
if(in_array(product['product_id'] , $wishids)
{ 
  //do something
}