note 109139 added to function.explode
| From: | david at saturnprods dot com | Date: | Fri, 22 Jun 2012 18:43:35 +0000 |
| Subject: | note 109139 added to function.explode | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-188757@lists.php.net to get a copy of this message | ||
function blowup($delimiter,$string){
if(strpos($string,$delimiter)===false){
return array($string);
}
else{
return explode($delimiter, $string);
}
}
returns you an array always. if it doesn't find the delimiter it simply returns the string but
as an array.
example:
echo blowup('@','cat@dog@mouse');
returns:
Array('cat','dog','mouse');
example:
echo blowup('@','cat');
returns:
Array('hello');
Useful if you have to have at least ONE option
----
Server IP: 69.147.83.197
Probable Submitter: 24.94.158.190
----
Manual Page -- http://www.php.net/manual/en/function.explode.php
Edit -- https://master.php.net/note/edit/109139
Del: integrated -- https://master.php.net/note/delete/109139/integrated
Del: useless -- https://master.php.net/note/delete/109139/useless
Del: bad code -- https://master.php.net/note/delete/109139/bad+code
Del: spam -- https://master.php.net/note/delete/109139/spam
Del: non-english -- https://master.php.net/note/delete/109139/non-english
Del: in docs -- https://master.php.net/note/delete/109139/in+docs
Del: other reasons-- https://master.php.net/note/delete/109139
Reject -- https://master.php.net/note/reject/109139
Search -- https://master.php.net/manage/user-notes.php