![](/img/trans.png)
[英]how to convert string to Array in php with file_get_contents?
[英]API REST php - How to String (file_get_contents) to an ARRAY?
我有這個代碼:
$res = file_get_contents("http://localhost:8080/restcolitas");
echo $res;
只需使用json_decode()函數
$res = json_decode($res);
該文件的內容似乎是一個json。 你可以這樣做:
$res = file_get_contents("http://localhost:8080/restcolitas");
$jsonToArray = json_decode($res, TRUE);
聲明:本站的技術帖子網頁,遵循CC BY-SA 4.0協議,如果您需要轉載,請注明本站網址或者原文地址。任何問題請咨詢:yoyou2525@163.com.