note 96567 added to function.preg-split
| From: | sergei dot garrison at gmail dot com | Date: | Fri, 05 Mar 2010 16:04:25 +0000 |
| Subject: | note 96567 added to function.preg-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-166705@lists.php.net to get a copy of this message | ||
If you need to split a list of "tags" while allowing for user error, you'll find this
more useful than the manual's first example.
<?php
$string = 'one, two,three, four , five,six seven';
$array = preg_split("/[\s]*[,][\s]*/", $string);
print_r($array);
// Array ( [0] => one [1] => two [2] => three [3] => four [4] => five [5] => six
seven )
?>
This splits the string *only* by commas, regardless of how many spaces there are on either side of
any comma.
----
Server IP: 69.147.83.197
Probable Submitter: 71.194.162.4
----
Manual Page -- http://www.php.net/manual/en/function.preg-split.php
Edit -- https://master.php.net/note/edit/96567
Del: integrated -- https://master.php.net/note/delete/96567/integrated
Del: useless -- https://master.php.net/note/delete/96567/useless
Del: bad code -- https://master.php.net/note/delete/96567/bad+code
Del: spam -- https://master.php.net/note/delete/96567/spam
Del: non-english -- https://master.php.net/note/delete/96567/non-english
Del: in docs -- https://master.php.net/note/delete/96567/in+docs
Del: other reasons-- https://master.php.net/note/delete/96567
Reject -- https://master.php.net/note/reject/96567
Search -- https://master.php.net/manage/user-notes.php