Jump to content

[SOLVED] array inside an array inside an array


wds

Recommended Posts

here's my dilemma, i want to create my cart array to house all of the customer's selections. the $image array will serve two purposes. $image will be used to identify which image they wish to purchase, and with each image there will be 3 values denoting the quantity of each size of picture they want (4x6, 5x8, & 8x10).

 

now, i can call for the value of $cart[3]['four'][0] just fine, as long as the sub-arrays "five" and "eight" do not exist. any ideas how to go about this?

 

 

 

THIS SCRIPT WORKS:

$image = 3;

$cart = array(

$image => array(

"four" => array(

"3"

)

)

);

print("<html><head></head><body>" . $cart[3]['four'][0] . "</body></html>");

 

 

THIS SCRIPT DOES NOT WORK:

$image = 3;

$cart = array(

$image => array(

"four" => array(

"3"

)

"five" => array(

"4"

)

"eight" => array(

"1"

)

)

);

print("<html><head></head><body>" . $cart[3]['four'][0] . "</body></html>");

 

 

THIS IS DRIVING ME CRAZY. Thank you for your input.

Link to comment
Share on other sites

u try ds....

THIS SCRIPT DOES NOT WORK:

$image = 3;

$cart = array(

  $image => array(

      "four" => array(

        "3"

      ),

      "five" => array(

        "4"

      ),

      "eight" => array(

        "1"

      )

  )

);

print("<html><head></head><body>" . $cart[3]['four'][0] . "</body></html>");

 

Link to comment
Share on other sites

clear, thank you so much!!! i can't believe it was just a simple syntax error... sometimes it's just the simplest things, i can't believe i overlooked that!!! i am so happy right now, cheers to you sir.

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.