RE: [PHP-WIN] pulling arrays from nested arrays?

From: Date: Mon, 05 Mar 2001 13:15:20 +0000
Subject: RE: [PHP-WIN] pulling arrays from nested arrays?
References: 1  Groups: php.windows 
Request: Send a blank email to php-windows+get-5828@lists.php.net to get a copy of this message
Hi Doug, could it be possible, that the $first_array["second array"] returns the string "array" instead of the array ?? A possible way to get a copy from your nested array is to write a function like this: $new_array = get_nested_array( $first_array, "second array" ); function get_nested_array( $array, $nested_array ) { while(list($key, $val) = each($array[$nested_array])) { $result_array[$key] = $val; } return ( $result_array ); } Yes, there may be a better solution =8) Greetinx, Mike Michael Rudel - Web-Development, Systemadministration - _______________________________________________________________ Suchtreffer AG Bleicherstraße 20 D-78467 Konstanz Germany fon: +49-(0)7531-89207-17 fax: +49-(0)7531-89207-13 e-mail: mailto:mru@suchtreffer.de internet: http://www.suchtreffer.de _______________________________________________________________ -----Original Message----- From: Doug Brewer [mailto:dbrewer@insightpd.com] Sent: Sunday, March 04, 2001 5:30 AM To: php-windows@lists.php.net Subject: RE: [PHP-WIN] pulling arrays from nested arrays? Perhaps I was unclear...I actually _want_ to modify the copy, that's why I made a copy, to preserve the original. My point was that this doesn't seem to create a valid copy of the original array: $new_array = $first_array["second array"]; Operations on $new_array seem to fail, because it isn't an array. Using a reference would modify the original, and I don't want to do that. Doug | -----Original Message----- | From: Ernest E Vogelsinger [mailto:ebird@1-at-web.at] | Sent: Saturday, March 03, 2001 7:17 PM | To: Doug Brewer | Cc: php-windows@lists.php.net | Subject: Re: [PHP-WIN] pulling arrays from nested arrays? | | | At 01:21 04.03.2001, Doug Brewer said: | --------------------[snip]-------------------- | >$new_array = $first_array["second array"]; # what's wrong | with this? | | this is a copy of $first_array["second array"]. | | >while(list($this, $that) = each($new_array)) { | > # doesn't work! | >} | | this modifies the copy! | | After applying the modifications, do | $first_array["second array"] = $new_array; | to replace the original with the modified contents. | | Usually you would use references to arrays to handle this, | but I haven't | found a way yet to get list() to return references instead | of copies... | | | ...ebird | | >O Ernest E. Vogelsinger | (\) http://www.1-at-web.at/ | ^ ICQ# 13394035 | | | -- | PHP Windows Mailing List (http://www.php.net/) | To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net | For additional commands, e-mail: php-windows-help@lists.php.net | To contact the list administrators, e-mail: | php-list-admin@lists.php.net | -- PHP Windows Mailing List (http://www.php.net/) To unsubscribe, e-mail: php-windows-unsubscribe@lists.php.net For additional commands, e-mail: php-windows-help@lists.php.net To contact the list administrators, e-mail: php-list-admin@lists.php.net

« previous php.windows (#5828) next »