php.net |  support |  documentation |  report a bug |  advanced search |  search howto |  statistics |  random bug |  login
Doc Bug #75901 (Chinese,zh)Example Diff with Other language, And Error
Submitted: 2018-02-01 03:36 UTC Modified: 2018-02-01 18:32 UTC
From: zhangshulin2008 at live dot cn Assigned: jhdxr (profile)
Status: Closed Package: Translation problem
PHP Version: 7.2Git-2018-02-01 (snap) OS: All
Private report: No CVE-ID: None
View Add Comment Developer Edit
Welcome! If you don't have a Git account, you can't do anything here.
You can add a comment by following this link or if you reported this bug, you can edit this bug over here.
(description)
Block user comment
Status: Assign to:
Package:
Bug Type:
Summary:
From: zhangshulin2008 at live dot cn
New email:
PHP Version: OS:

 

 [2018-02-01 03:36 UTC] zhangshulin2008 at live dot cn
Description:
------------
Documentation "New Features in 7.1" translation for Chinese:
No.3 Symmetric array destructuring

http://php.net/manual/zh/migration71.new-features.php
In Chinese:
Zh:
短数组语法([])现在可以用于将数组的值赋给一些变量(包括在foreach中)。 这种方式使从数组中提取值变得更为容易。

<?php
$data = [
    ['id' => 1, 'name' => 'Tom'],
    ['id' => 2, 'name' => 'Fred'],
];

while (['id' => $id, 'name' => $name] = $data) {
    // logic here with $id and $name
}



http://php.net/manual/en/migration71.new-features.php
In Other:
En:
Symmetric array destructuring ¶
The shorthand array syntax ([]) may now be used to destructure arrays for assignments (including within foreach), as an alternative to the existing list() syntax, which is still supported.

<?php
$data = [
    [1, 'Tom'],
    [2, 'Fred'],
];

// list() style
list($id1, $name1) = $data[0];

// [] style
[$id1, $name1] = $data[0];

// list() style
foreach ($data as list($id, $name)) {
    // logic here with $id and $name
}

// [] style
foreach ($data as [$id, $name]) {
    // logic here with $id and $name
}

JA:
配列の短縮構文 ([]) を使って、 代入用に配列の値を取り出せるようになりました (foreach でも使えます)。 これは、list() の代替として使えます (list() もまだ使えます)。

<?php
$data = [
    [1, 'Tom'],
    [2, 'Fred'],
];

// list() 形式
list($id1, $name1) = $data[0];

// [] 形式
[$id1, $name1] = $data[0];

// list() 形式
foreach ($data as list($id, $name)) {
    // $id と $name を使う処理をここに書きます
}

// [] 形式
foreach ($data as [$id, $name]) {
    // $id と $name を使う処理をここに書きます
}


Test script:
---------------
/

Expected result:
----------------
/

Actual result:
--------------
/

Patches

Add a Patch

Pull Requests

Add a Pull Request

History

AllCommentsChangesGit/SVN commitsRelated reports
 [2018-02-01 15:07 UTC] jhdxr@php.net
-Status: Open +Status: Assigned -Assigned To: +Assigned To: jhdxr
 [2018-02-01 15:07 UTC] jhdxr@php.net
Looks like the Chinese version is out-of-date, I'll update it later.
 [2018-02-01 18:32 UTC] jhdxr@php.net
Automatic comment from SVN on behalf of jhdxr
Revision: http://svn.php.net/viewvc/?view=revision&amp;revision=344155
Log: sync with latest en version
fix bug #75901
 [2018-02-01 18:32 UTC] jhdxr@php.net
-Status: Assigned +Status: Closed
 [2018-02-01 18:32 UTC] jhdxr@php.net
This bug has been fixed in the documentation's XML sources. Since the
online and downloadable versions of the documentation need some time
to get updated, we would like to ask you to be a bit patient.

Thank you for the report, and for helping us make our documentation better.


 [2020-12-30 10:47 UTC] nikic@php.net
Automatic comment on behalf of jhdxr
Revision: http://git.php.net/?p=doc/zh.git;a=commit;h=27a35895d20e961054ee4d93a3c385227d3992fc
Log: sync with latest en version fix bug #75901
 
PHP Copyright © 2001-2024 The PHP Group
All rights reserved.
Last updated: Fri Mar 29 10:01:28 2024 UTC