This is probably because of the line
$j+1;
your both variables ($i and $j) are not being updated in the while loop, causing an infinite loop. ( checking the same values all the time, if the condition is true an infinite loop, else the code will never enter the loop and exit. )
change $j+1;
with either $j++;
or $j = $j + 1;
Moreover as @apomene shows,
if your array can have multiple types,
The !==
operator checks both the type and the equality. If your array has same types ( for e.g int ) this would not create a problem tho. With the same types !==
and !=
are the same thing practically. Else, it (!==
) also checks for type equality. To elaborate,
$a = 1;
$b = '1';
$c = 2;
$d = 1;
$a == $b // TRUE ( different type, equal after conversion - char <-> int)
$a === $b // FALSE( different types - int vs char)
$a == $c // FALSE( same type not equal)
$a === $d // TRUE ( same type and equal)
Further reading available in this question.
Lastly, you seem to have a confusion between assignment and comparison of a variable. ( $i = $j
vs $i == $j
)
Check the php manual for assignment vs comparison of variables.