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.

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>");

 

Archived

This topic is now archived and is closed to further replies.

×
×
  • 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.