FUDforum
Fast Uncompromising Discussions. FUDforum will get your users talking.

Home » Imported messages » comp.lang.php » Inserting into associative array
Show: Today's Messages :: Polls :: Message Navigator
Return to the default flat view Create a new topic Submit Reply
Re: Inserting into associative array [message #169995 is a reply to message #169903] Mon, 04 October 2010 03:25 Go to previous message
Peter H. Coffin is currently offline  Peter H. Coffin
Messages: 245
Registered: September 2010
Karma:
Senior Member
On Wed, 29 Sep 2010 21:31:54 +0200, Jonathan Stein wrote:
> Hi.
>
> Let's say I have an array like
> array(
> 'fruit' => 'banana',
> 'color' => 'yellow'
> )
>
> Now I want to insert
> 'shape' => 'round'
> between 'fruit' and 'color'. I would think that PHP had a simple
> solution for that, but I haven't found it... My solution is to loop
> through the original array and build a new one.
>
> Does anyone have a better solution?

Why do you care where it is? It's an associative array. You access it by
keys.

--
"Meet it is I set it down
That one may smile, and smile, and be a villain"
[Message index]
 
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Read Message
Previous Topic: PHP 5.3.3 Crashes on Win7
Next Topic: Dot in array key name
Goto Forum:
  

-=] Back to Top [=-
[ Syndicate this forum (XML) ] [ RSS ]

Current Time: Fri Sep 20 20:40:38 GMT 2024

Total time taken to generate the page: 0.06646 seconds