note 14072 deleted from function.strtr by jimw

From: Date: Fri, 14 Dec 2001 20:35:19 +0000
Subject: note 14072 deleted from function.strtr by jimw
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-22762@lists.php.net to get a copy of this message
This code replaces something like "abc";"def";"ghi" to an array with its cells. Watch out, strtr will not replace '"' to an empty string, that's why I use trim(strtr($cell,'"',' ')) and replace the " to a blank and trim then. <? $path="../locations/"; $file=$path."location.txt"; $arr=memo_read($file); echo "<table border=1>"; foreach ($arr as $elem) { echo "<tr>"; $tok=explode(";",$elem); foreach ($tok as $cell) { echo "<td>".trim(strtr($cell,'"',' '))."</td>"; } echo "</tr>"; } echo "</table>"; function memo_read ($file) { $file_arr=file($file); return $file_arr; }

« previous php.notes (#22762) next »