note 19577 added to function.explode

From: Date: Mon, 04 Mar 2002 16:20:57 +0000
Subject: note 19577 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-27321@lists.php.net to get a copy of this message
If you have a line with multiple seperator symbols between elements, for example " ", like this one: $line = "192.168.68.60 0x1 0x2 00:E0:1E:7F:D5:26 * eth1" to get rid of null values while exploding you can do something like this: $line = preg_replace("/\s+/", " ", $line); $elements = explode(" ", $out); Here you replace 1 or more whitespace characters (\s+) with single whitespace character " " (a seperator in this case), and then just explode the whole stuff. -- http://www.php.net/manual/en/function.explode.php http://master.php.net/manage/user-notes.php?action=edit+19577 http://master.php.net/manage/user-notes.php?action=delete+19577 http://master.php.net/manage/user-notes.php?action=reject+19577

« previous php.notes (#27321) next »