mirror of
https://github.com/sigmasternchen/php-doc-en
synced 2025-03-16 00:48:54 +00:00
fixed looping example
git-svn-id: https://svn.php.net/repository/phpdoc/en/trunk@149633 c90b9560-bf6c-de11-be94-00142212c4b1
This commit is contained in:
parent
f3b95bb58b
commit
d83d498490
1 changed files with 5 additions and 10 deletions
|
@ -1,5 +1,5 @@
|
|||
<?xml version="1.0" encoding="iso-8859-1"?>
|
||||
<!-- $Revision: 1.1 $ -->
|
||||
<!-- $Revision: 1.2 $ -->
|
||||
<reference id="ref.simplexml">
|
||||
<title>SimpleXML functions</title>
|
||||
<titleabbrev>SimpleXML</titleabbrev>
|
||||
|
@ -36,7 +36,7 @@
|
|||
<para>
|
||||
<example>
|
||||
<title>Include file example.php with XML string</title>
|
||||
<programlisting role="php">
|
||||
<programlisting role="php" id="simplexml.examples.movie">
|
||||
<![CDATA[
|
||||
<?php
|
||||
$xmlstr = <<<XML
|
||||
|
@ -99,14 +99,9 @@ include 'example.php';
|
|||
|
||||
$xml = simplexml_load_string($xmlstr);
|
||||
|
||||
/* For each <movie> node, we echo a separate <plot>.
|
||||
* [foreach() could be used, but for() stands in place
|
||||
* as using foreach() on large XML documents will
|
||||
* create undesirable memory overhead.] */
|
||||
|
||||
$mid_count = count($movies);
|
||||
for($mid = 0; $mid < $mid_count; ++$mid) {
|
||||
echo $movies[$mid]->plot,'<br/>';
|
||||
/* For each <movie> node, we echo a separate <plot>. */
|
||||
foreach($xml->movie as $movie) {
|
||||
echo $movie->plot,'<br/>';
|
||||
}
|
||||
|
||||
?>
|
||||
|
|
Loading…
Reference in a new issue