note 19577 deleted from function.explode by didou
| From: | didou@php.net | Date: | Sun, 07 Dec 2003 03:11:57 +0000 |
| Subject: | note 19577 deleted from function.explode by didou | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-61579@lists.php.net to get a copy of this message | ||
Note Submitter: elf@elf.dammit.lt
----
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.