Welcome to the Treehouse Community
Want to collaborate on code errors? Have bugs you need feedback on? Looking for an extra set of eyes on your latest project? Get support with fellow developers, designers, and programmers of all backgrounds and skill levels here with the Treehouse Community!
Looking to learn something new?
Treehouse offers a seven day free trial for new students. Get access to thousands of hours of content and join thousands of Treehouse students and alumni in the community today.
Start your free trial

Unsubscribed User
8,167 PointsEcho out an Array within another Array?
I am trying to echo an array within another array...here is the code
$products = array();
$products[101] = array(
"a" => "Blue & White Stripes",
"b" => 35,
"c" => "img/shirts.jpg",
"d" => "Red",
"e" => array("Small", "Medium", "Large", "X-Large"),
"f" => "img.jpg",
"g" => "Orange"
);
I am trying to echo out the array within $product["e"].
Does anyone know how to do this?
3 Answers

Unsubscribed User
8,167 PointsSorry the array messed up
$products = array();
$products[101] = array(
"a" => "Blue & White Stripes",
"b" => 35,
"c" => "img/shirt.jpg",
"d" => "Red",
"e" => array("Small", "Medium", "Large", "X-Large"),
"f" => "img.jpg",
"d" => "Orange"
);

Randy Hoyt
Treehouse Guest TeacherSomething like this?
<?php
foreach($product["e"] as $size) {
echo $size;
}
?>

Unsubscribed User
8,167 PointsThat worked! Thanks for the help Randy.