Programming Tutorials

(追記) (追記ここまで)

Traversing Arrays Using list() and each() in PHP

By: Andi, Stig and Derick in PHP Tutorials on 2008年11月22日 [フレーム]

Although foreach() is the nicer way of iterating over an array, an additional way of traversing an array is by using a combination of the list() construct and the each() function:

$players = array("John", "Barbara", "Bill", "Nancy");
reset($players);
while (list($key, $val) = each($players)) {
print "#$key = $val\n";
}

The output of this example is

#0 = John
#1 = Barbara
#2 = Bill
#3 = Nancy



(追記) (追記ここまで)


Add Comment

JavaScript must be enabled for certain features to work
* Required information
1000

Comments

No comments yet. Be the first!
(追記) (追記ここまで)
(追記) (追記ここまで)

AltStyle によって変換されたページ (->オリジナル) /