note 67835 added to function.file

From: Date: Wed, 05 Jul 2006 20:24:57 +0000
Subject: note 67835 added to function.file
Groups: php.notes 
Request: Send a blank email to php-notes+get-114414@lists.php.net to get a copy of this message
Here's a simple text file to data array converter: function file_to_data($sFileIn, $Separator = "|") { $aFile = array_map("rtrim", file($sFileIn)); $aResult = array(); foreach ($aFile as $FileString) { $aResult[] = explode($Separator, $FileString); } return $arrResult; } Here's an example: File.dat contains... apple|1|red orange|2|orange {eof} Execute function... $aData = file_to_data("File.dat"); Results... $aData[0] $aData[0][0] = "apple" $aData[0][1] = "1" $aData[0][2] = "red" $aData[1] $aData[1][0] = "orange" $aData[1][1] = "2" $aData[1][2] = "orange" ---- Server IP: 216.194.113.175 Probable Submitter: 66.217.117.38 ---- X-Spam-Status: No, hits=3.1 required=5.0 tests=DATE_MISSING,FROM_NO_LOWER autolearn=no version=2.64 ---- Manual Page -- http://www.php.net/manual/en/function.file.php Edit -- http://master.php.net/note/edit/67835 Del: integrated -- http://master.php.net/note/delete/67835/integrated Del: useless -- http://master.php.net/note/delete/67835/useless Del: bad code -- http://master.php.net/note/delete/67835/bad+code Del: spam -- http://master.php.net/note/delete/67835/spam Del: non-english -- http://master.php.net/note/delete/67835/non-english Del: in docs -- http://master.php.net/note/delete/67835/in+docs Del: other reasons-- http://master.php.net/note/delete/67835 Reject -- http://master.php.net/note/reject/67835 Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#114414) next »