php - 有没有办法重新构造 file_get_contents 输出?php
问题描述
我试图从 json 文件中获取一些信息,该页面中的代码是这样的
{"asignaciones":[{"fecha":"LUNES 29/07","horaEntrada":"18:30","horaSalida":"22:30","tienda":"BK Villa Urquiza"}], "fechaConsulta":"29/07/2019 17:27","legajo":"28907"}
我想拍“29/7”、“18:30”、“22:30”。现在,我可以打印页面中的所有代码,但我只想获取这些数字,有一种方法:file_get_contents?
如果这个问题非常简单,我正在尝试学习更多 php 对不起。
我现在的代码:
$content = file_get_contents('http://proveedores.alsea.com.ar:48080/asignaciones-server/mobile/main/asignaciones/legajos/28907');
echo $content
?>
解决方案
看起来内容是一个json......从这个开始:
$content = file_get_contents('http://proveedores.alsea.com.ar:48080/asignaciones-server/mobile/main/asignaciones/legajos/28907');
$content = json_decode($content);
print_r($content);