note 70427 added to ref.array
| From: | r2rien at gmail dot com | Date: | Mon, 16 Oct 2006 12:06:41 +0000 |
| Subject: | note 70427 added to ref.array | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-118570@lists.php.net to get a copy of this message | ||
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
)
----
Server IP: 217.174.203.10
Probable Submitter: 80.170.97.32
----
Manual Page -- http://www.php.net/manual/en/ref.array.php
Edit -- https://master.php.net/note/edit/70427
Del: integrated -- https://master.php.net/note/delete/70427/integrated
Del: useless -- https://master.php.net/note/delete/70427/useless
Del: bad code -- https://master.php.net/note/delete/70427/bad+code
Del: spam -- https://master.php.net/note/delete/70427/spam
Del: non-english -- https://master.php.net/note/delete/70427/non-english
Del: in docs -- https://master.php.net/note/delete/70427/in+docs
Del: other reasons-- https://master.php.net/note/delete/70427
Reject -- https://master.php.net/note/reject/70427
Search -- https://master.php.net/manage/user-notes.php