As i remember, before i always had to check count($array) before making a foreach. From that times i always make this doublecheck, and wanted to know, does it make sense nowdays with php 5.4?
I've set error_reporting to E_ALL and executed following script:
$x = [];
foreach($x as $y) {
var_dump($y);
}
and got no notice (as i remember, previously, perhaps it was php5.3) i was getting notice.
Is it safe now using foreach on array, that is empty?
null
though, that's another story. – BattisteInvalid argument supplied for foreach()
? Wouldn't show on an array but would if you have defined the var but not as an array. – Ji