<?php
$grid = array();

$ren = array("tallas","nom_talla1","nom_talla2");
array_push($grid,$ren);
$ren = array("participacion","0.024","0.19");
array_push($grid,$ren);
$ren = array("00 CDS","1","0");
array_push($grid,$ren);
$ren = array("011 POL","0","1");
array_push($grid,$ren);

// muestra en una tabla
$maxlen = sizeof($grid);
$tablarow = "grid<table border=3>";
for($renx = 0; $renx < $maxlen; $renx++) {
    $maxsub = sizeof($grid[$renx]);

    $tablarow .= "<tr>";
    for($coly = 0; $coly < $maxsub; $coly++) {
        $tablarow .= "<td>".$grid[$renx][$coly]."</td>";
    }
    $tablarow .= "</tr>";

}
$tablarow .= "</table>"; 
echo $tablarow;

$renx--;
// ahora interactuamos con el arreglo
$tablarow = "grid<table border=3>";
for( $renx; $renx >= 0 ; $renx-- ) {
    $maxsub = sizeof($grid[$renx]);

    $tablarow .= "<tr>";
    for($coly = 0; $coly < $maxsub; $coly++) {
        $tablarow .= "<td>".$grid[$renx][$coly]."</td>";
    }
    $tablarow .= "</tr>";

}
$tablarow .= "</table>"; 
echo $tablarow;


/*


$grid = array();

$row = array(
	// Ankit will act as key
	"00 CDS" => array(
		
		// Subject and marks are
		// the key value pair
		"talla1" => 95,
		"talla2" => 85,
		"talla3" => 74,
    ));
array_push($grid,$row);

$row = array(
	// Ankit will act as key
	"011 POL" => array(
		
		// Subject and marks are
		// the key value pair
		"talla1" => 95,
		"talla2" => 85,
		"talla3" => 74,
    ));
array_push($grid,$row);

print_r($grid);
echo "<hr>";
$maxlen = sizeof($grid);
for($i = 0; $i < $maxlen; $i++) {
    $maxsub = sizeof($grid[$i]);
    for($j = 0; $j < $maxsub; $j++) {
        echo "<hr>".$grid[$i][$j];
    }
}




$registros = array(
    array(
        'id' => 2135,
        'nombre' => 'John',
        'apellido' => 'Doe'
    ),
    array(
        'id' => 3245,
        'nombre' => 'Sally',
        'apellido' => 'Smith'
    ),
    array(
        'id' => 5342,
        'nombre' => 'Jane',
        'apellido' => 'Jones'
    ),
    array(
        'id' => 5623,
        'nombre' => 'Peter',
        'apellido' => 'Doe'
    )
); 

$maxlen = sizeof($registros);
$tablarow = "registros<table border=3>";
for($i = 0; $i < $maxlen; $i++) {
    $maxsub = sizeof($registros[$i]);

    $tablarow .= "<tr>";
    for($j = 0; $j < $maxsub; $j++) {
        $tablarow .= "<td>".$registros[$i][$j]."</td>";
    }
    $tablarow .= "</tr>";

}
$tablarow .= "</table>"; 
echo $tablarow;

$out  = "";
$out .= "<table border=2>";
$out .= "<tr>";
foreach($registros as $key => $element) $out .= "<td>$key</td>";
$out .= "</tr>";
foreach($registros as $key => $element){
    $out .= "<tr>";
    foreach($element as $subkey => $subelement){
        $out .= "<td>$subelement</td>";
    }
    $out .= "</tr>";
}
$out .= "</table>";

echo $out;

// PHP program to creating two
// dimensional associative array
$marks = array(
	
	// Ankit will act as key
	"Tienda" => array(
		
		// Subject and marks are
		// the key value pair
		"0" => "00 CDS",
		"1" => "011 POL",
		"2" => 74,
	),
		
	// Ram will act as key
	"Talla 38" => array(
		
		// Subject and marks are
		// the key value pair
		"0" => 78,
		"1" => 98,
		"2" => 46,
	),
	
	// Anoop will act as key
	"Talla 40" => array(
		
		// Subject and marks are
		// the key value pair
		"0" => 88,
		"1" => 46,
		"2" => 99,
	),
);

$maxlen = sizeof($marks);
$tablarow = "marks<table border=3>";
for($i = 0; $i < $maxlen; $i++) {
    $maxsub = sizeof($marks[$i]);

    $tablarow .= "<tr>";
    for($j = 0; $j < $maxsub; $j++) {
        $tablarow .= "<td>".$marks[$i][$j]."</td>";
    }
    $tablarow .= "</tr>";

}
$tablarow .= "</table>"; 
echo $tablarow;

echo "Display Marks: \n";
	
print_r($marks);

$out  = "";
$out .= "<table border=2>";
$out .= "<tr>";
foreach($marks as $key => $element) $out .= "<td>$key</td>";
$out .= "</tr>";
foreach($marks as $key => $element){
    $out .= "<tr>";
    foreach($element as $subkey => $subelement){
        $out .= "<td>$subelement</td>";
    }
    $out .= "</tr>";
}
$out .= "</table>";

echo $out;

$maxlen = sizeof($marks);
for($i = 0; $i < $maxlen; $i++) {
    $maxsub = sizeof($marks[$i]);
    for($j = 0; $j < $maxsub; $j++) {
        echo "<hr>".$marks[$i][$j];
    }
}
*/
?>
