Welcome Guest, Not a member yet? Register   Sign In
Kindof a php question.. but..re: adding to arrays
#5

[eluser]Dam1an[/eluser]
[quote author="octavianmh" date="1240506848"]
Anyway, I don't really love the standard array() method recommended above, I wish array_push were working like the php documentation says it would. Smile They claim this should work fine:

Code:
Ariz Jacinto
27-Jun-2008 11:41
if you're going to use array_push() to insert a "$key" => "$value" pair into an array, it can be done using the following example:

    array_push($data[$key], $value);
    ...
    array_push($data[$key], $value);
[/quote]

First of all, 'they' in this case is refering to a user, not an author of the PHP project
Secondly, the description states
Quote:array_push() treats array as a stack, and pushes the passed variables onto the end of array . The length of array increases by the number of variables pushed.
which states the item gets added to the end of the array

It then goes on to state if you just want to add a single value, use th $array['key'] = ... notation

Hope this clears things up a bit


Messages In This Thread
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-22-2009, 06:50 PM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-22-2009, 07:44 PM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-22-2009, 11:37 PM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-23-2009, 06:14 AM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-23-2009, 06:49 AM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-23-2009, 06:50 AM
Kindof a php question.. but..re: adding to arrays - by El Forum - 04-23-2009, 06:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB