On Wed, Jun 26, 2024, at 09:54, Rob Landers wrote: > > > On Wed, Jun 26, 2024, at 00:19, Morgan wrote: >> On 2024-06-26 08:24, Rob Landers wrote: >> > On Tue, Jun 25, 2024, at 20:23, Ilija Tovilo wrote: >> >> >> If null array values were indeed unobservable, then [] would be === to >> >> [null] (or at least ==), and a foreach over [null] would result in 0 >> >> iterations. But neither of those are the case. >> > >> > I think there is a difference between an empty array and a null, and >> > that is (hopefully) self-evident. I’m talking about the infinite nulls >> > IN the array. You can write a for loop of all possible keys until the >> > end of the universe, and all you will get is null. This is fairly easy >> > to prove. I'll wait... :p >> > >> What about the difference between an empty array an an array that >> contains a null (Ilija's example)? >> >> echo count([]); >> echo count([null]); >> echo count([null, null]); >> echo count([null, null, null]); >> echo count([null, null, null, null]); >> ... >> >> You're arguing that these are all the same array? >> > > If you are accessing them by index, yes, they are all the same array. There > is no observable difference. I think we already covered that count() would > show the difference between them since it’s actually a count of known indices:
Sorry, I’ve not yet had enough coffee, this should be: $arr = []; for($i = 0; $i < 4; $i++) var_dump($arr[$i]); > > Will output 4 nulls. > > > — Rob — Rob