note 113461 added to function.file
| From: | bingo at dingo dot com | Date: | Mon, 14 Oct 2013 12:36:52 +0000 |
| Subject: | note 113461 added to function.file | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-196550@lists.php.net to get a copy of this message | ||
To write all the lines of the file in other words to read the file line by line you can write the
code like this:
<?php
$names=file('name.txt');
// To check the number of lines
echo count($names).'<br>';
foreach($names as $name)
{
echo $name.'<br>';
}
?>
this example is so basic to understand how it's working. I hope it will help many beginners.
Regards,
Bingo
----
Server IP: 69.147.83.199
Probable Submitter: 110.93.210.21
----
Manual Page -- http://php.net/manual/en/function.file.php
Edit -- https://master.php.net/note/edit/113461
Del: integrated -- https://master.php.net/note/delete/113461/integrated
Del: useless -- https://master.php.net/note/delete/113461/useless
Del: bad code -- https://master.php.net/note/delete/113461/bad+code
Del: spam -- https://master.php.net/note/delete/113461/spam
Del: non-english -- https://master.php.net/note/delete/113461/non-english
Del: in docs -- https://master.php.net/note/delete/113461/in+docs
Del: other reasons-- https://master.php.net/note/delete/113461
Reject -- https://master.php.net/note/reject/113461
Search -- https://master.php.net/manage/user-notes.php