note 125644 added to function.list
| From: | mark at manngo dot net | Date: | Wed, 30 Dec 2020 03:46:56 +0000 |
| Subject: | note 125644 added to function.list | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-216044@lists.php.net to get a copy of this message | ||
For PHP 7.1 on, the documentation states that integer and string keys can be mixed, but that
elements with and without keys cannot. Here is an example, using data from getimagesize() with mixed
keys:
<?php
$data=[
0=> 160,
1 => 120,
2 => 2,
3 => 'width="160" height="120"',
'mime' => 'image/jpeg'
];
list(0=>$width,1=>$height,2=>$type,3=>$dimensions,'mime'=>$mime)=$data;
?>
Here, the numeric keys also need to be specified, as if the whole array is treated as an associative
array.
As noted elsewhere, the list() operator can be written in array format:
<?php
[0=>$width,1=>$height,2=>$type,3=>$dimensions,'mime'=>$mime]=$data;
?>
----
Server IP: 45.112.84.4
Probable Submitter: 101.0.109.162 (proxied: 121.200.24.221)
----
Manual Page -- http://php.net/manual/en/function.list.php
Edit -- https://master.php.net/note/edit/125644
Del: integrated -- https://master.php.net/note/delete/125644/integrated
Del: useless -- https://master.php.net/note/delete/125644/useless
Del: bad code -- https://master.php.net/note/delete/125644/bad+code
Del: spam -- https://master.php.net/note/delete/125644/spam
Del: non-english -- https://master.php.net/note/delete/125644/non-english
Del: in docs -- https://master.php.net/note/delete/125644/in+docs
Del: other reasons-- https://master.php.net/note/delete/125644
Reject -- https://master.php.net/note/reject/125644
Search -- https://master.php.net/manage/user-notes.php