note 60352 deleted from function.explode by tularis
| From: | tularis@php.net | Date: | Wed, 04 Jan 2006 18:03:59 +0000 |
| Subject: | note 60352 deleted from function.explode by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-101208@lists.php.net to get a copy of this message | ||
Note Submitter: fred at sillylife dot com
Reason: useless
----
Cute little trick:
If you are trying to split a string that may have one or two results in the array, and you wish to
do so to a list without getting warnings, here's how to do it:
$s = "ftgod";
$r = "ftgod-gold";
@list($a, $b) = explode('-', $s, 2);
list($c, $d) = explode('-', $r, 2);
echo "a=$a, b=$b, c=$c, d=$d";
var_dump($b);
Note that $b comes out NULL, which you can test for, of course.