note 101144 added to function.array-replace
| From: | polecat at p0lecat dot com | Date: | Mon, 29 Nov 2010 17:57:30 +0000 |
| Subject: | note 101144 added to function.array-replace | ||
| Groups: | php.notes | ||
| Request: | Send a blank email to php-notes+get-174445@lists.php.net to get a copy of this message | ||
I would like to add to my previous note about my polecat_array_replace function that if you want to
add a single dimensional array to a multi, all you must do is pass the matching internal array key
from the multi as the initial argument as such:
$array1 = array( "berries" => array( "strawberry" => array(
"color" => "red", "food" => "desserts"),
"dewberry" = array( "color" => "dark violet", "food"
=> "pies"), );
$array2 = array( "food" => "wine");
$array1["berries"]["dewberry"] =
polecat_array_replace($array1["berries"]["dewberry"], $array2);
This is will replace the value for "food" for "dewberry" with "wine".
The function will also do the reverse and add a multi to a single dimensional array or even a 2 tier
array to a 5 tier as long as the heirarchy tree is identical.
I hope this helps atleast one person for all that I've gained from this site.
----
Server IP: 69.147.83.197
Probable Submitter: 70.241.103.180
----
Manual Page -- http://www.php.net/manual/en/function.array-replace.php
Edit -- https://master.php.net/note/edit/101144
Del: integrated -- https://master.php.net/note/delete/101144/integrated
Del: useless -- https://master.php.net/note/delete/101144/useless
Del: bad code -- https://master.php.net/note/delete/101144/bad+code
Del: spam -- https://master.php.net/note/delete/101144/spam
Del: non-english -- https://master.php.net/note/delete/101144/non-english
Del: in docs -- https://master.php.net/note/delete/101144/in+docs
Del: other reasons-- https://master.php.net/note/delete/101144
Reject -- https://master.php.net/note/reject/101144
Search -- https://master.php.net/manage/user-notes.php