I have a array which has string and array.
I am trying to get the all the values with foreach but it does not work. It seems simple but I am stuck with this. If anybody can tell me where to fix, that would be very great. Thank you in advance.
<?php
$shirts = array();
$shirts[101] = array(
"size" => "Large",
"img" => array("images/nike1.jpg","images/nike2.jpg","images/nike3.jpg"),
"price" => "$30";
);
$shirts[102] = array(
"size" => "Small",
"img" => array("images/adidas1.jpg","images/adidas2.jpg","images/adidas3.jpg"),
"price" => "$30";
);
$shirts[103] = array(
"size" => "Medium",
"img" => array("images/puma1.jpg","images/puma2.jpg","images/puma3.jpg"),
"price" => "$30";
);
$last = count($shirts) - 1;
foreach ($shirts as $i => $row){
$isFirst = ($i == 0);
$isLast = ($i == $last);
if (is_array($row)){
$lastChild = count($row) - 1;
foreach ($row as $j =>$rowChild){
$isFirstChild = ($j == 0);
$isLastChild = ($j == $lastChild);
echo $rowChild;
}
}else{
echo $row;
}
}
?>
I am trying to get the all the values
what do you want at the end? – Cheery Oct 21 at 4:17