I have the following arrangement;
$datos = array(
"nombre" => array("Juan Perez","Pablo Manrique","Nancy Peña"),
"direccion" => array("Cra. 45 # 45 -56","Clle. 23 # 12 -19 Sur","Av. 34 # 16 -12"),
"telefono" => array("3456789","3214567","2135423"),
"fecha" => array("23/12/1997","12/10/1980"," 07/06/2000"),
"color" => array("Amarillo","Verde","Verde"),
"significado" => array("Riqueza yalegría.","No se encuentra el significado","")
);
And I'm looking for a way to do a single validation and print a table on the screen with the data found in each array, but I get everything in one column.
What I want to do is something like this,
This is the condition
If the name of the color exists in a second array that contains: the name of the color and the meaning of each one, if found, it is necessary to write the meaning of the color in a last column of the Table, otherwise you must write the phrase “Meaning not found”.
This is what I tried:
echo "<table border=1><tr><th>nombre</th>
<th>direccion</th>
<th>telefono</th>
<th>fecha</th>
<th>color</th>
<th>significado</th></tr>";
foreach ($datos as $value)
{
echo "<tr><td>".$value[0]."<td></tr>";
echo "<tr><td>".$value[1]."<td></tr>";
echo "<tr><td>".$value[2]."<td></tr>";
}
Here is the script:
The idea is to iterate through the columns of your data array, assigning each of the arrays to each column.
Finally they are iterated and the table is rendered.
Cheers,
If all your arrays have the same length then you could do this: