Php, in_array with no exactly match

Posted by John Smith on Stack Overflow See other posts from Stack Overflow or by John Smith
Published on 2014-06-05T09:22:45Z Indexed on 2014/06/05 9:24 UTC
Read the original article Hit count: 132

Filed under:
|

I want to do the following:

$a = array();
$a[] = array(1,2);
$a[] = array(2,5);
$a[] = array(3,4);
var_dump (in_array(array(2,5), $a));

this returns OK, as it expected, but if the source array is not fully matched:

$a = array();
$a[] = array(1,2, 'f' => array());
$a[] = array(2,5, 'f' => array());
$a[] = array(3,4, 'f' => array());
var_dump (in_array(array(2,5), $a));

it returns false. Is there a way to do it with the built-in way, or I have to code it?

© Stack Overflow or respective owner

Related posts about php

Related posts about arrays