Json 如何从这个php构建参数/查询?
我想从这段php代码中构建参数/查询Json 如何从这个php构建参数/查询?,json,parameters,file-get-contents,Json,Parameters,File Get Contents,我想从这段php代码中构建参数/查询 $url = 'https://link.com/search?url='; ///Try to fetch compressed content using the file_get_contents function $opts = array( 'http'=>array( 'method'=>"GET", 'header'=>"Accept-language: en\r\n"
$url = 'https://link.com/search?url=';
///Try to fetch compressed content using the file_get_contents function
$opts = array(
'http'=>array(
'method'=>"GET",
'header'=>"Accept-language: en\r\n" .
"Cookie: foo=bar\r\n" . // check function.stream-context-create on php.net
"User-Agent: Mozilla/5.0 (iPad; U; CPU OS 3_2 like Mac OS X; en-us) AppleWebKit/531.21.10 (KHTML, like Gecko) Version/4.0.4 Mobile/7B334b Safari/531.21.102011-10-16 20:23:10\r\n" // i.e. An iPad
)
);
$context = stream_context_create($opts);
$zipped_content = file_get_contents($url ,false,$context);
$json = json_encode($zipped_content,true);
$str = str_replace('\\', '/', $json);
$str2 = str_replace('////', '//', $str);
$str3 = str_replace('//', '/', $str2);
$str4 = str_replace('https:/', 'https://', $str3);
preg_match_all('!https://[a-z0-9\-\.\/]+\.(?:jpe?g|png|gif)!Ui' , $str4 , $result);
foreach ($result[0] as $url)
{
echo $url . "<br />\n";
}
可以这样使用
localhost/test.php?什么东西=https://google.com
怎么做?
另外,提前谢谢!
对不起,我的英语不好
$url = 'https://link.com/search?url=".$stuff."';