Doc #74064 [Fbk->NoF]: [ZH] 这个也能错???

From: Date: Sun, 26 Feb 2017 04:22:31 +0000
Subject: Doc #74064 [Fbk->NoF]: [ZH] 这个也能错???
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14464@lists.php.net to get a copy of this message
Edit report at https://bugs.php.net/bug.php?id=74064&edit=1

 ID:               74064
 Updated by:       php-bugs@lists.php.net
 Reported by:      bhg at live dot it
 Summary:          [ZH] 这个也能错???
-Status:           Feedback
+Status:           No Feedback
 Type:             Documentation Problem
 Package:          Translation problem
 Operating System: Windows
 PHP Version:      7.1.1
 Private report:   N

 New Comment:

No feedback was provided. The bug is being suspended because
we assume that you are no longer experiencing the problem.
If this is not the case and you are able to provide the
information that was requested earlier, please do so and
change the status of the bug back to "Re-Opened". Thank you.


Previous Comments:
------------------------------------------------------------------------
[2017-02-13 06:13:47] laruence@php.net

你想说哪里错了? 
what the problem here?

thanks

------------------------------------------------------------------------
[2017-02-09 01:27:26] bhg at live dot it

Description:
------------
---
From manual page: http://php.net/manual/zh/migration71.new-features.php
---


Test script:
---------------
$data = [
    ['id' => 1, 'name' => 'Tom'],
    ['id' => 2, 'name' => 'Fred'],
];

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

Expected result:
----------------
$data = [
    ["id" => 1, "name" => 'Tom'],
    ["id" => 2, "name" => 'Fred'],
];

// list() style
list("id" => $id1, "name" => $name1) = $data[0];

// [] style
["id" => $id1, "name" => $name1] = $data[0];

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

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

Actual result:
--------------
$data = [
    ['id' => 1, 'name' => 'Tom'],
    ['id' => 2, 'name' => 'Fred'],
];

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


------------------------------------------------------------------------



--
Edit this bug report at https://bugs.php.net/bug.php?id=74064&edit=1


Thread (3 messages)

« previous php.doc.bugs (#14464) next »