I try to search array in array, but function doesn't work:
$a = [];
$b = [];
array_push($a,"1");
array_push($a,"2");
array_push($b,"2");
dd(array_search($b,$a));
How I can search array values in other array?
I try to search array in array, but function doesn't work:
$a = [];
$b = [];
array_push($a,"1");
array_push($a,"2");
array_push($b,"2");
dd(array_search($b,$a));
How I can search array values in other array?
You can't simply get that searched by built in function but if you intent to get array that match from $b into $a you can do it by using
print_r( array_intersect($a, $b) );
Input
$a = [];
$b = [];
array_push($a,"1");
array_push($a,"2");
array_push($a, "3");
array_push($b,"2");
array_push($b, '1');
print_r( array_intersect($a, $b) );
echo !empty(array_intersect($a, $b));
output
Array
(
[0] => 1
[1] => 2
)