note 18290 added to function.explode

From: Date: Thu, 17 Jan 2002 10:54:57 +0000
Subject: note 18290 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-24973@lists.php.net to get a copy of this message
sometimes a problem may occur, if user add a separator char at the end: "item1, item2, item3, item4,", so the last would be an empty array-item. you can fix this with using $string = trim($string,$separator); additionally it would be useful to get rid of the spaces leading (or following) each item: $string = trim($string,$separator); $strarray = explode($separator,$string); foreach ($strarray as $stritem) $stritem = trim($stritem); hope this helps, + stefan -- http://www.php.net/manual/en/function.explode.php http://master.php.net/manage/user-notes.php?action=edit+18290 http://master.php.net/manage/user-notes.php?action=delete+18290 http://master.php.net/manage/user-notes.php?action=reject+18290

« previous php.notes (#24973) next »