Re: Insert new array after specific key in multidimensional array
| From: | Micky Hulse | Date: | Tue, 28 Feb 2012 04:43:06 +0000 |
| Subject: | Re: Insert new array after specific key in multidimensional array | ||
| References: | 1 2 3 4 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-316787@lists.php.net to get a copy of this message | ||
Hi Xucheng,
On Mon, Feb 27, 2012 at 7:41 PM, xucheng <helloworldjerry@gmail.com> wrote:
> Maybe you can trans the array into a xml tree , then modify its leaves .
Now that sounds like an interesting idea... I will have to research
that as an option. Thanks for tip! :)
@Eray,
I was not able to get your code to work on my array... After working
with it a little bit, I realized your idea was very similar to these
others that I have found (great minds think alike):
http://eosrei.net/articles/2011/11/php-arrayinsertafter-arrayinsertbefore
http://drupal.org/node/66183
Your suggestion, and the ones above, work great if I "break out" the
key, pass it directly, then add the key back to the original array.
I have updated my gist and also put the code here:
<http://codepad.org/IY0y9Oy6>
Could things be optimized, or is this an acceptable solution?
Thanks!
Cheers,
Micky