philip Thu Oct 17 22:15:03 2002 EDT
Modified files:
/phpdoc/en/reference/filesystem/functions file.xml
Log:
Rewrote example using foreach instead of while/list. Expanded the comments.
See also file_get_contents() and include().
Index: phpdoc/en/reference/filesystem/functions/file.xml
diff -u phpdoc/en/reference/filesystem/functions/file.xml:1.3
phpdoc/en/reference/filesystem/functions/file.xml:1.4
--- phpdoc/en/reference/filesystem/functions/file.xml:1.3 Thu Sep 26 09:56:53
2002
+++ phpdoc/en/reference/filesystem/functions/file.xml Thu Oct 17 22:15:02 2002
@@ -1,5 +1,5 @@
<?xml version="1.0" encoding="iso-8859-1"?>
-<!-- $Revision: 1.3 $ -->
+<!-- $Revision: 1.4 $ -->
<!-- splitted from ./en/functions/filesystem.xml, last change in rev 1.2 -->
<refentry id="function.file">
<refnamediv>
@@ -37,14 +37,17 @@
<programlisting role="php">
<![CDATA[
<?php
-// get a web page into an array and print it out
-$fcontents = file ('http://www.example.com/');
-while (list ($line_num, $line) = each ($fcontents)) {
- echo "<b>Line $line_num:</b>; ", htmlspecialchars ($line), "<br>\n";
+// Get a file into an array. In this example we'll go through HTTP to get
+// the HTML source of a URL.
+$lines = file ('http://www.example.com/');
+
+// Loop through our array, show html source as html source; and line numbers too.
+foreach ($lines as $line_num => $line) {
+ echo "Line #<b>{$line_num}</b> : " . htmlspecialchars($line) . "<br>\n";
}
-// get a web page into a string
-$fcontents = implode ('', file ('http://www.example.com/'));
+// Another example, let's get a web page into a string. See also file_get_contents().
+$html = implode ('', file ('http://www.example.com/'));
?>
]]>
</programlisting>
@@ -61,7 +64,8 @@
<para>
See also <function>readfile</function>,
<function>fopen</function>, <function>fsockopen</function>, and
- <function>popen</function>.
+ <function>popen</function>, and <function>file_get_contents</function>,
+ and <function>include</function>.
</para>
</refsect1>
</refentry>
--
PHP Documentation Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php