我想在fsockopen中转换此代码:
$z = $_GET['z'];
$z = str_replace(' ', '%20', $z);
if("$z")
{
$file = file("http://example.com/$z");
}else{
$file = file("http://example.com/main/");
}
$file = @implode("", $file);
$file = str_replace('/main/', '?z=main/', $file);
echo $file;
你帮我吗?
答案 0 :(得分:0)
试试这个:
function replaceDomain($url = null){
$parts = explode('.com/', $url);
return $parts[0].'.com/index.php?z='.$parts[1];
}
$url = "http://example.com/downloads/programs/100";
echo replaceDomain($url);
输出:
http://example.com/index.php?z=downloads/programs/100