php获取文件的结果\u获取\u内容作为数组
我正在尝试从url接收响应,如下所示:php获取文件的结果\u获取\u内容作为数组,php,Php,我正在尝试从url接收响应,如下所示: $result = file_get_contents('http://example.com/api/test'); 它只返回一些由| 例如: info1|info2|info3 我想得到一个数组的结果 类似于$result=array(file\u get\u contents('http://example.com/api/test')); 我刚刚参与了php的工作,请原谅我有任何混淆的术语 我刚拿到 explode("|",$result);
$result = file_get_contents('http://example.com/api/test');
它只返回一些由|
例如:
info1|info2|info3
我想得到一个数组的结果
类似于$result=array(file\u get\u contents('http://example.com/api/test'));代码>
我刚刚参与了php的工作,请原谅我有任何混淆的术语 我刚拿到
explode("|",$result);
您可以使用explode()
按管道分隔数据
$result = explode('|',file_get_contents('http://example.com/api/test'))
操作非常简单:
$resultArray = explode("|", $result);
googlephp explode
获取该字符串并使用explode()
将其转换为数组。这里有一个链接:下次,在发布之前搜索。