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

From: Date: Mon, 13 Feb 2017 06:13:48 +0000
Subject: Doc #74064 [Opn->Fbk]: [ZH] 这个也能错???
References: 1  Groups: php.doc.bugs 
Request: Send a blank email to doc-bugs+get-14436@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: laruence@php.net Reported by: bhg at live dot it Summary: [ZH] 这个也能错??? -Status: Open +Status: Feedback Type: Documentation Problem Package: Translation problem Operating System: Windows PHP Version: 7.1.1 Block user comment: N Private report: N New Comment: 你想说哪里错了? what the problem here? thanks Previous Comments: ------------------------------------------------------------------------ [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

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