note 16471 added to function.explode

From: Date: Thu, 01 Nov 2001 03:33:12 +0000
Subject: note 16471 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-19955@lists.php.net to get a copy of this message
explode gave me a bit of trouble when I used it to convert a txt file to a list. The last element in the array was null so I used strlen to filter it. $list_of_exists = file_exists($list_of); if ($list_of_exists) { $listname = ($list_of); $listcon = fopen ($list_of, "r"); $contents = fread ($listcon, filesize ($listname)); fclose ($listcon); $stuff = explode ("\r", $contents); print "some html"; for ($k = "0"; $k < count($stuff); $k++) { if (strlen ($stuff[$k]) > 5){ print "some html" . $stuff[$k]; }} print "some html"; } Hope this can be a help to someone... Miles B -- http://www.php.net/manual/en/function.explode.php http://master.php.net/manage/user-notes.php?action=edit+16471 http://master.php.net/manage/user-notes.php?action=delete+16471 http://master.php.net/manage/user-notes.php?action=reject+16471

« previous php.notes (#19955) next »