note 104618 added to function.preg-split
| From: | david dot binovec at gmail dot com | Date: | Sun, 26 Jun 2011 13:38:28 +0000 |
| Subject: | note 104618 added to function.preg-split | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-180960@lists.php.net to get a copy of this message | ||
Limit = 1 may be confusing. The important thing is that in case of limit equals to 1 will produce
only ONE substring. Ergo the only one substring will be the first one as well as the last one. Tnat
the rest of the string (after the first delimiter) will be placed to the last substring. But last is
the first and only one.
<?php
$output = $preg_split('(/ /)', '1 2 3 4 5 6 7 8', 1);
echo $output[0] //will return whole string!;
$output = $preg_split('(/ /)', '1 2 3 4 5 6 7 8', 2);
echo $output[0] //will return 1;
echo $output[1] //will return '2 3 4 5 6 7 8';
?>
----
Server IP: 69.147.83.197
Probable Submitter: 85.70.92.159
----
Manual Page -- http://www.php.net/manual/en/function.preg-split.php
Edit -- https://master.php.net/note/edit/104618
Del: integrated -- https://master.php.net/note/delete/104618/integrated
Del: useless -- https://master.php.net/note/delete/104618/useless
Del: bad code -- https://master.php.net/note/delete/104618/bad+code
Del: spam -- https://master.php.net/note/delete/104618/spam
Del: non-english -- https://master.php.net/note/delete/104618/non-english
Del: in docs -- https://master.php.net/note/delete/104618/in+docs
Del: other reasons-- https://master.php.net/note/delete/104618
Reject -- https://master.php.net/note/reject/104618
Search -- https://master.php.net/manage/user-notes.php