note 60352 added to function.explode

From: Date: Wed, 04 Jan 2006 17:31:16 +0000
Subject: note 60352 added to function.explode
Groups: php.notes 
Request: Send a blank email to php-notes+get-101205@lists.php.net to get a copy of this message
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. ---- Manual Page -- http://www.php.net/manual/en/function.explode.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60352 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60352&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60352&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60352&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60352&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60352&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60352&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60352&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60352&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101205) next »