3 ms·
Consistency. Since $a[0] is a string, you would expect $a[0][0] to work too.
by fooyc 15y ago
Consistency. Since $a[0] is a string, you would expect $a[0][0] to work too.
- function_seven 15y agoThanks. Let me rework my original question then. Why the hell didn't it always work? php > $a = "Hello"; php > echo $a[0]; H php > echo $a[0][0]; PHP Fatal error: Cannot use string offset as an array in php shell code on line 1
- tlack 15y agoPHP always seemed to have something weird in the parser about subscripts/array indexes. It's been there since I started using it during PHP3. Another similar fix they performed is making func()[0] work - before you had to do $tmp = func(); $tmp[0]. An old, old bug finally fixed.