note 102319 added to function.file-get-contents
| From: | YogaWibowoAji at osu1 dot php dot net | Date: | Tue, 08 Feb 2011 17:10:23 +0000 |
| Subject: | note 102319 added to function.file-get-contents | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-176783@lists.php.net to get a copy of this message | ||
read text per line and convert to array
for example, the input file is input.txt
the input file containt text below
one
two
three
four
five
++++++++++++++++++++++++++
read value per line
<?php
$data = file_get_contents("input.txt"); //read the file
$convert = explode("\n", $data); //create array separate by new line
for ($i=0;$i<count($convert);$i++)
{
echo $convert[$i].', '; //write value by index
}
?>
++++++++++++++++++++++++++
Output :
one, two, three, four, five,
----
Server IP: 202.158.52.162
Probable Submitter: 180.246.35.194
----
Manual Page -- http://www.php.net/manual/en/function.file-get-contents.php
Edit -- https://master.php.net/note/edit/102319
Del: integrated -- https://master.php.net/note/delete/102319/integrated
Del: useless -- https://master.php.net/note/delete/102319/useless
Del: bad code -- https://master.php.net/note/delete/102319/bad+code
Del: spam -- https://master.php.net/note/delete/102319/spam
Del: non-english -- https://master.php.net/note/delete/102319/non-english
Del: in docs -- https://master.php.net/note/delete/102319/in+docs
Del: other reasons-- https://master.php.net/note/delete/102319
Reject -- https://master.php.net/note/reject/102319
Search -- https://master.php.net/manage/user-notes.php