Reputation: 25
This is what I have achieved so far.
$product1 = array("Watch"=>"100$", "Shoes"=>"550$", "Jacket"=>"430$" , "Sweater"=>"230$" );
$product2 = array("Watch"=>"200$", "Shoes"=>"450$", "Jacket"=>"430$" , "Sweater"=>"230$" );
$product3 = array("Watch"=>"300$", "Shoes"=>"350$", "Jacket"=>"430$" , "Sweater"=>"230$" );
$product4 = array("Watch"=>"400$", "Shoes"=>"250$", "Jacket"=>"430$" , "Sweater"=>"230$" );
foreach($product1 as $x => $x_value) {
echo "Name=" . $x ."<br>". ", Price=" . $x_value."<br>";
}
foreach($product2 as $x => $x_value) {
echo "Name=" . $x ."<br>". ", Price=" . $x_value."<br>";
}
I want the product1 output in 1st row and in first four columns. Similary product2 output in 2nd row and in four columns.
Upvotes: 0
Views: 65
Reputation:
What about something like that:
echo '<table>';
echo '<tr>';
foreach ($product1 as $x => $x_value) {
echo '<td>';
echo "Name=" . $x ."<br>". "Price=" . $x_value;
echo '</td>';
}
echo '</tr>';
echo '<tr>';
foreach ($product2 as $x => $x_value) {
echo '<td>';
echo "Name=" . $x ."<br>". "Price=" . $x_value;
echo '</td>';
}
echo '</tr>';
echo '<tr>';
foreach ($product3 as $x => $x_value) {
echo '<td>';
echo "Name=" . $x ."<br>". "Price=" . $x_value;
echo '</td>';
}
echo '</tr>';
echo '<tr>';
foreach ($product4 as $x => $x_value) {
echo '<td>';
echo "Name=" . $x ."<br>". "Price=" . $x_value;
echo '</td>';
}
echo '</tr>';
echo '</table>';
Upvotes: 1