note 119563 deleted from function.preg-split by tularis
| From: | tularis@php.net | Date: | Thu, 07 Jul 2016 15:49:10 +0000 |
| Subject: | note 119563 deleted from function.preg-split by tularis | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-205916@lists.php.net to get a copy of this message | ||
Note Submitter: ztaz
----
$str = "a=1&b=2&c=3&d=4";
$arr = preg_split("/[=&]/", $str);
$arr2 = array_combine(
array_filter($arr, create_function('$k', 'return !($k&1);'),
ARRAY_FILTER_USE_KEY),
array_filter($arr, create_function('$k', 'return ($k&1);'),
ARRAY_FILTER_USE_KEY)
);
$arr1:
Array
(
[0] => a
[1] => 1
[2] => b
[3] => 2
[4] => c
[5] => 3
[6] => d
[7] => 4
)
$arr2:
Array
(
[a] => 1
[b] => 2
[c] => 3
[d] => 4
)