如何获得Url数据需要提取为数组格式


How to get Url data need to extract as array format

如何从url内部数据作为数组格式在php。

http://ekkanoo.com/api/NewsFeeds/json/toyota-news/0/15?callback=

我已经尝试了各种代码,但我不能得到作为数组格式。

如果你想把你的url设置为array那么你可能要找的是explode

ref - explosion

假设您的文件有以下代码

index . php

<!DOCTYPE html>
<html lang="en">
<head>
    <meta charset="UTF-8">
    <title>Test jQuery</title>
    <script src="../jquery-1.7.2.js"></script>   
</head>
<body>
    <div id="new_div"></div>
</body>
</html>

获取url文件的内容

<?php 
  $fileString = file_get_contents("index.php");
  $fileArr = explode("'n",$string);
  print_r($fileArr);
  ?>

输出
Array
(
    [0] => <!DOCTYPE html>
    [1] => <html lang="en">
    [2] => <head>
    [3] =>  <meta charset="UTF-8">
    [4] =>  <title>Test jquery</title>
    [5] =>  <script src="../jquery-1.7.2.js"></script>   
    [6] => </head>
    [7] => 
    [8] => <body>
    [9] =>  <div id="new_div"></div>
    [10] => </body>
    [11] => </html>
)

据我所知,您需要这个http://php.net/manual/en/function.parse-url.php

来自文档:

这个函数解析一个URL并返回一个关联数组,其中包含URL中存在的各种组件中的任意一个。该函数并不打算验证给定的URL,它只是将其分解为上面列出的部分。部分url也可以接受,parse_url()会尽力正确解析它们