[DOC-CVS] [doc-en] master: filesystem: Clean up fgetcsv example (#5769)

[email protected] (Mikhail Alferov via GitHub)
Newsgroups php.doc.cvs
Message-ID <[email protected]>
Author: Mikhail Alferov (mmalferov)
Committer: GitHub (web-flow)
Pusher: jordikroon
Date: 2026-08-18T19:50:43+02:00

Commit: https://github.com/php/doc-en/commit/9936f6b7df4f01883b41f60d06fb438e9bf7e667
Raw diff: https://github.com/php/doc-en/commit/9936f6b7df4f01883b41f60d06fb438e9bf7e667.diff

filesystem: Clean up fgetcsv example (#5769)

* Clean up fgetcsv example

Changed paths:
  M  reference/filesystem/functions/fgetcsv.xml


Diff:

diff --git a/reference/filesystem/functions/fgetcsv.xml b/reference/filesystem/functions/fgetcsv.xml
index 48cdd62375ea..7c61c470259d 100644
--- a/reference/filesystem/functions/fgetcsv.xml
+++ b/reference/filesystem/functions/fgetcsv.xml
@@ -200,19 +200,26 @@
     <programlisting role="php">
 <![CDATA[
 <?php
-$row = 1;
-if (($handle = fopen("test.csv", "r")) !== FALSE) {
-    while (($data = fgetcsv($handle, 1000, ",")) !== FALSE) {
-        $num = count($data);
-        echo "<p> $num fields in line $row: <br /></p>\n";
-        $row++;
-        for ($c=0; $c < $num; $c++) {
-            echo $data[$c] . "<br />\n";
+
+if (($handle = fopen("test.csv", "r")) !== false) {
+    $row = 1;
+
+    while (($fields = fgetcsv($handle, 1000, ",", "\"", "\\")) !== false) {
+        $num = count($fields);
+
+        echo "\n<p>$num fields in line $row:</p>\n<ol>";
+
+        for ($c = 0; $c < $num; $c++) {
+            echo "\n\t<li>", $fields[$c], "</li>";
         }
+
+        echo "\n</ol>";
+
+        $row++;
     }
+
     fclose($handle);
 }
-?>
 ]]>
     </programlisting>
    </example>
lmpx.com only provides a reader for public news (NNTP) servers. It is not affiliated with the servers or forums shown here and is not responsible for the content of articles, which is written by their respective authors.