arrays have me confused...

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
User avatar
J_Iceman05
Forum Commoner
Posts: 72
Joined: Wed Aug 03, 2005 10:52 am
Location: Las Vegas, NV

arrays have me confused...

Post 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.
josh
DevNet Master
Posts: 4872
Joined: Wed Feb 11, 2004 3:23 pm
Location: Palm beach, Florida

Post by josh »

Code: Select all

$array['name']='value';
User avatar
J_Iceman05
Forum Commoner
Posts: 72
Joined: Wed Aug 03, 2005 10:52 am
Location: Las Vegas, NV

Post by J_Iceman05 »

ok, thank you very much.
Post Reply