簡體   English   中英

"API REST php - 如何將(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.

 
粵ICP備18138465號  © 2020-2024 STACKOOM.COM