Search code examples
phppreg-matchfile-get-contents

is there a way to reestructure file_get_contents output? php


Im triyng to take some information from a json file, the code in that page is like this

{"asignaciones":[{"fecha":"LUNES 29/07","horaEntrada":"18:30","horaSalida":"22:30","tienda":" BK Villa Urquiza"}],"fechaConsulta":"29/07/2019 17:27","legajo":"28907"}

i want to take "29/7", "18:30", "22:30". For now, i can print all the code in my page, but i want to take only those numbers, there is a way with:file_get_contents?

i'm trying to learn a little more php sorry if this question is oviously simple.

my code now:

$content = file_get_contents('http://proveedores.alsea.com.ar:48080/asignaciones-server/mobile/main/asignaciones/legajos/28907');

echo $content



?>

Solution

  • It looks like the content is a json... Start from this:

    $content = file_get_contents('http://proveedores.alsea.com.ar:48080/asignaciones-server/mobile/main/asignaciones/legajos/28907');
    $content = json_decode($content);
    print_r($content);