note 53431 added to function.explode

From: Date: Wed, 01 Jun 2005 12:29:18 +0000
Subject: note 53431 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-89735@lists.php.net to get a copy of this message
Here's how to split a text file into lines using explode(). This could be very useful for restoring backed up databases, when you need to pass every line (SQL statement) to MYSQL separatly: $theFile = file_get_contents('file.txt'); $lines = array(); $lines = explode("\n", $theFile); $lineCount = count($lines); for ($i = 0; $i < $lineCount; $i++){ echo $lines[$i]."<hr>"; }//for The text lines are split by a horizontal line so you can see the effect in the browser ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+53431 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+53431&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+53431&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+53431&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+53431&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+53431&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+53431&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#89735) next »