Search code examples
coldfusioncoldfusion-9

ArrayApend on Multidimensional Array - Coldfusion


Is there a way to append data to a 3D array with arrayAppend? I am trying to create a shopping cart and I need to add each item with quantity, price, and shipping location together


Solution

  • 3D array? It may be easier to have an array of struct's.

    cart = [
      {
        qty: 2,
        price: 3.99,
        shippingLocation: "somewhere"
      }
    ];
    
    arrayAppend(cart, {
        qty: 3,
        price: 19.99,
        shippingLocation: "somewhere else"
    });