note 121909 added to language.types.array
| From: | liberchen at gmail dot com | Date: | Thu, 23 Nov 2017 15:34:03 +0000 |
| Subject: | note 121909 added to language.types.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-209210@lists.php.net to get a copy of this message | ||
Since PHP 7.1, the string will not be converted to array automatically.
Below codes will fail:
$a=array();
$a['a']='';
$a['a']['b']='';
//Warning: Illegal string offset 'b'
//Warning: Cannot assign an empty string to a string offset
You have to change to as below:
$a=array();
$a['a']=array(); // Declare it is an array first
$a['a']['b']='';
----
Server IP: 208.43.231.9
Probable Submitter: 39.12.62.115
----
Manual Page -- http://php.net/manual/en/language.types.array.php
Edit -- https://master.php.net/note/edit/121909
Del: integrated -- https://master.php.net/note/delete/121909/integrated
Del: useless -- https://master.php.net/note/delete/121909/useless
Del: bad code -- https://master.php.net/note/delete/121909/bad+code
Del: spam -- https://master.php.net/note/delete/121909/spam
Del: non-english -- https://master.php.net/note/delete/121909/non-english
Del: in docs -- https://master.php.net/note/delete/121909/in+docs
Del: other reasons-- https://master.php.net/note/delete/121909
Reject -- https://master.php.net/note/reject/121909
Search -- https://master.php.net/manage/user-notes.php