Reputation: 205
Hello i got a question, i have a session array called 'addToCart', in there are multiple arrays with various id's, i would like to loop through these arrays with a foreach regardless of what the id name is. Does anyone know how i would approach this?
Upvotes: 0
Views: 486
Reputation: 7780
Does the following construction satisfy your needs?
foreach ($addToChart as $key=>$value){
// do anything you want with $key and $value
}
If you need to check "sub-arrays", you can check $value with is_array() function and add one more foreach loop inside.
Upvotes: 3