mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-15 08:28:54 +00:00
Replace each() with foreach in usort and simplexmlelement/xpath
This commit is contained in:
parent
6be77ad626
commit
08e0e7dd68
2 changed files with 3 additions and 3 deletions
|
@ -154,7 +154,7 @@ $fruits[2]["fruit"] = "grapes";
|
|||
|
||||
usort($fruits, "cmp");
|
||||
|
||||
while (list($key, $value) = each($fruits)) {
|
||||
foreach ($fruits as $key => $value) {
|
||||
echo "\$fruits[$key]: " . $value["fruit"] . "\n";
|
||||
}
|
||||
?>
|
||||
|
|
|
@ -67,14 +67,14 @@ $xml = new SimpleXMLElement($string);
|
|||
/* Search for <a><b><c> */
|
||||
$result = $xml->xpath('/a/b/c');
|
||||
|
||||
while(list( , $node) = each($result)) {
|
||||
foreach ($result as $node) {
|
||||
echo '/a/b/c: ',$node,"\n";
|
||||
}
|
||||
|
||||
/* Relative paths also work... */
|
||||
$result = $xml->xpath('b/c');
|
||||
|
||||
while(list( , $node) = each($result)) {
|
||||
foreach ($result as $node) {
|
||||
echo 'b/c: ',$node,"\n";
|
||||
}
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue