Re: Insert new array after specific key in multidimensional array
| From: | Micky Hulse | Date: | Tue, 28 Feb 2012 22:01:25 +0000 |
| Subject: | Re: Insert new array after specific key in multidimensional array | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-316789@lists.php.net to get a copy of this message | ||
On Tue, Feb 28, 2012 at 8:36 AM, Shawn McKenzie <nospam@mckenzies.net> wrote:
> Might be an easier way but this should work. You can sort the $before =
> true out for yourself :-)
Hi Shawn, I've updated your function to do the $before bit:
<https://gist.github.com/1928452#file_array_insert.php>
I also set it up to merge the new array to the end if the key does not exist.
Out of all the examples I have found, your approach looks the cleanest
and the most compact.
I'm open to feedback.
Many thanks!!!!
Cheers,
M