I have created a restful api that obtains a list of coordinates that are stored in a database that follows the following format: / devices / 1 / gpses / 0, where the first number is the identifier of the device we want to see and the second is since when we want to obtain data, in Unix Timestamp format. For a specific date you do not have any problem. My question is whether I want to obtain the data between two specific dates. The beginning of the code I have more or less calro:
$fechaInicial = strtotime($fechaInicial);
$fechaFinal = strtotime($fechaFinal);
$posicionesIntermedia = $this->obtenerUnSeguimiento($dispositivoId, $fechaInicial);
And I know that the next thing would be to do a path of $posicionesIntermedias
discarding all those data that are greater than $fechaFinal
. But I do not know how to focus the foreach.
I forgot to say that the answer of the api is a json composed of the data fecha
, dispositivo_id
, latitud
and longitud
Any help?
EDIT: I add the method code to get aSegment ()
protected function obtenerUnSeguimiento($id, $fecha)
{
$respuesta = $this->realizarPeticion('GET', "https://localhost/dispositivos/{$id}/gpses/{$fecha}");
$datos = json_decode($respuesta);
$posiciones = $datos->data;
return $posiciones;
}