Skip to content
Advertisement

Printing a nested array on View | Codeigniter

I’m building a cart using sessions, I’m adding each pizza to an array and passing to the session. The array is as follows,

JavaScript

I was able to display the item id, pizza name, price, and quantity But cannot figure out to display the topping names user has selected in the Toppings column.How should I do this>

View

The following code shows the way that I’m getting values from array,

JavaScript

Output

The output that I’m expecting is as follows

Item ID |Item Name|Price|Toppings(selected topping names)|Quantity

The list is not displaying I’m getting the error “Undefined index: name”.

Advertisement

Answer

You must make a loop over topping since that is also array, so you can check for each item in it.

JavaScript

?>

User contributions licensed under: CC BY-SA
7 People found this is helpful
Advertisement