lundi 2 septembre 2019

Looping through an array, within an array

I want to loop through an array within and array. I'm new to loops and I am struggling reading through the documentation.

$data holds the below.

Array
(
    [products] => Array
        (
            [0] => Product1
            [1] => Product2
        )
)

I'm wanting to use foreach loop and i have tried.

foreach($data as $key){
    echo $key->products
}

I want to be able to echo out Product 1 and Product 2 separately.



via Chebli Mohamed

Aucun commentaire:

Enregistrer un commentaire