Interesting behavior comparing integer with array in PHP -


in php had compare if integer variable less value of array, had error in code , found chance unexpected behavior.

i comparing integer array , returning true. know why?

i've been searching in stackoverflow , php.net (php types comparisons) , didn't found specific answer.

here have little code test this.

<?php  $myarray = array(); $myint = 1;  if($myint < $myarray){     echo "int less array\n"; }  if($myint == $myarray){     echo "int equal array\n"; }  if($myint > $myarray){     echo "int greater array\n"; } 

i've tried different values $myint , different contents $myarray , prints this:

int less array 

comparing array else result in array greater :

see php doc - section comparison various types


Comments