note 14072 added to function.strtr.php
| From: | b-sept at gmx dot de | Date: | Mon, 16 Jul 2001 10:42:11 +0000 |
| Subject: | note 14072 added to function.strtr.php | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-15423@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;
}
http://www.php.net/manual/en/function.strtr.php