mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 16:38:54 +00:00
[80538] Shorthand syntax for array destruction (#477)
* Shorthand syntax for array destruction * Remove reference to PHP 7.0 or lower * Bring back mention of list() prior to 7.1.0 * Replace array destruction with destructuring Co-authored-by: Kamil Tekiela <tekiela246@gmail.com> Co-authored-by: Anna Filina <afilina@gmail.com> Co-authored-by: Kamil Tekiela <tekiela246@gmail.com>
This commit is contained in:
parent
65f1e1978c
commit
1499a2369c
1 changed files with 7 additions and 2 deletions
|
@ -739,9 +739,14 @@ echo square(4); // outputs '16'.
|
|||
<?php
|
||||
function small_numbers()
|
||||
{
|
||||
return array (0, 1, 2);
|
||||
return [0, 1, 2];
|
||||
}
|
||||
list ($zero, $one, $two) = small_numbers();
|
||||
// Array destructuring will collect each member of the array individually
|
||||
[$zero, $one, $two] = small_numbers();
|
||||
|
||||
// Prior to 7.1.0, the only equivalent alternative is using list() construct
|
||||
list($zero, $one, $two) = small_numbers();
|
||||
|
||||
?>
|
||||
]]>
|
||||
</programlisting>
|
||||
|
|
Loading…
Reference in a new issue