Page 1 of 1

arrays have me confused...

Posted: Wed Aug 03, 2005 11:15 am
by J_Iceman05
If I have an array hard-coded like this...

Code: Select all

array(
    "product_code"                 => "123-aaa",
    "product_description"        => "milk",
    "product_price"                 => '$2.00',
    "product_active"               => "1",
    "product_imageurl_big"     => "img/milk_big.gif",
    "product_imageurl_small"  => "img/milk_small.gif"
)
but i also want to add extra items, such as a price for different membership cards a person has. example is 1 dollar for regular membership and 50 cents for premium membership, but the store may have no membership plans or 2, or 3 or any amount... so the number is unknown.
currently with other parts of the code, i check the database for the number, and use that number when doing other things, and it works quite well... but this one seems to have a problem since it is setup differently i can't use a while loop in the array creation, how can I set a name for the item name in the array? something like array_push, but from what i understand, you can't name the array item you are creating. Is there some other method that would make this possible? thank you for any help with this problem.

Posted: Wed Aug 03, 2005 11:56 am
by josh

Code: Select all

$array['name']='value';

Posted: Wed Aug 03, 2005 2:30 pm
by J_Iceman05
ok, thank you very much.