I'm quite new to PHP... I am trying to check if a value exists in my $Session array
and then display the content according to that but it is always showing 'Match not found' even when I know the value does exist in the array.
This is a print_r
of my array:
Array (
[0] => Array (
[0] => SIEMENS
[1] => 523-096-32
[2] => 1
[3] => New
)
)
When I do:
$array = $_SESSION['arr'];
if( in_array( "523-096-32" , $array ) ){
echo "Match found";
}else{
echo "Match not found";
}
The result is "Match not found".
I have also tried replacing in_array
with array_key_exists
but I'm having the same result.
My question is: where am I going wrong and how can I fix it to display "Match found"? Any help would be greatly appreciated.