note 70427 deleted from ref.array by felipe
| From: | felipe@php.net | Date: | Sun, 30 Dec 2007 19:26:54 +0000 |
| Subject: | note 70427 deleted from ref.array by felipe | ||
| References: | 1 | Groups: | php.notes |
| Request: | Send a blank email to php-notes+get-134514@lists.php.net to get a copy of this message | ||
Note Submitter: r2rien at gmail dot com
----
Regarding the string to array (parse_array) function posted by Kevin Law(thanks) and urlencoded by
vinaur(thanks) ,
The function will not work correctly if you use integer values as keys.
Thus I exchanged array_merge with a simple combined operator.
For example dealing with 4digit year strings as keys; parse_array(2006:abc,B:bcd) will produce
=> with array_merge:
<?php //...
$result = array_merge($result, parse_line2array(substr($line,$comma_pos+1)));
//...
$result = array_merge($result, parse_line2array($line));
//... ?>
Array (
[0] => abc
[B] => bcd
)
=> with combined operator:
<?php //...
$result += parse_line2array(substr($line,$comma_pos+1));
//...
$result += parse_line2array($line);
//... ?>
Array
(
[2006] => abc
[B] => bcd
)