A JSON
is answering the following:
[
{
emple_cedula: "7913",
emple_nombre: "PEPITO",
emple_apellido: "PEREZ",
resultado: "60"
},
{
emple_cedula: "7913",
emple_nombre: "PEPITO",
emple_apellido: "PEREZ",
resultado: "50"
},
{
emple_cedula: "987654",
emple_nombre: "VANESSA",
emple_apellido: "PAZ",
resultado: "100"
},
{
emple_cedula: "987654",
emple_nombre: "VANESSA",
emple_apellido: "PAZ",
resultado: "73"
},
]
How could I make php
show me a single name with all the results assigned to it?
Example:
7913 PEPITO PEREZ 60 50 <-(Estos son los resultados)
987654 VANESSA PAZ 100 73 <-(Estos son los resultados)
PHP CODE
if($response)
{
$personal = array();
foreach ($response as $respuesta)
{
if (!in_array(array($respuesta->emple_cedula, $respuesta->emple_nombre,$respuesta->emple_apellido), $personal)) {
$personal[] = array($respuesta->emple_cedula, $respuesta->emple_nombre,$respuesta->emple_apellido,);
}
}
$datos['personal'] = $personal;
echo json_encode($datos);
}
With this code, when I see that I'm printing echo json_encode ($ data), it sends me this:
7913 PEPITO PEREZ
987654 VANESSA PAZ
But then what should I do in my php code to print it?
7913 PEPITO PEREZ 60 50
987654 VANESSA PAZ 100 73
?
I would appreciate the interest.