Why can't I access the exploded array element immediately? Why can't I access the exploded array element immediately? arrays arrays

Why can't I access the exploded array element immediately?


The reason it isn't obvious how to do what you want is that explode could return false. You should check the return value before indexing into it.


It's version dependent. PHP 5.4 does support accessing the returned array.

Source: http://php.net/manual/en/language.types.array.php#example-115


Actually, PHP simply does not support this syntax. In languages like Javascript (for instance), the parser can handle more complex nesting/chaining operations, but PHP is not one of those languages.