17c01-1.php

来自「介绍PHP5的给类型函数应用」· PHP 代码 · 共 29 行

PHP
29
字号
<?php// Using SimpleXML, read the file into memory:$xml = simplexml_load_file('17c00-1.xml');//$xml = simplexml_load_file('contacts.xml');// Let's print out a formatted version of some of this contact data:// Start with an ordered list:echo "<ol>\n";// Loop over each contact:foreach ($xml->contact as $c) {    // Print their name:    echo '<li>' . $c->name;        // Now start an Unordered list for their phone numbers:    echo '<ul>';        // Loop over every phone number for this person:    foreach ($c->phone as $p) {        // Echo out a line including the type of number:        // The attribute will be accesible as if it were an assoc array        // entry.  Using the entry itself, will echo it's value.        echo '<li>', ucfirst($p['type']), ': ', $p, '</li>';    }        // Close off the phone list:    echo "</ul></li>\n";}    ?>

⌨️ 快捷键说明

复制代码Ctrl + C
搜索代码Ctrl + F
全屏模式F11
增大字号Ctrl + =
减小字号Ctrl + -
显示快捷键?