以下是我自己弄的!
建立個 123.php檔案 如下
$url = "http://www.123456.com/Ajax.ashx?Action=AddOrder&OrderIDShow=1&id=10086&Amt=10&Mb=2&Email=fdhfdf@qq.com"; $result = file_get_contents($url); echo $result;
顯示出的結果是 YES_5e286f3e
可是我想把 YES_去掉 單單顯示出 5e286f3e 請問我需要怎麼做! 本人小菜一個,望高手能幫忙解答!
回複討論(解決方案)
你去到結果後如果你只是想去掉YES_那你完全可以採用正則或者是切割按照_來切割取後面的就好了。
$str = "YES_5e286f3e";$arr = explode('_',$str);echo $arr[1];
$url = "http://www.123456.com/Ajax.ashx?Action=AddOrder&OrderIDShow=1&id=10086&Amt=10&Mb=2&Email=fdhfdf@qq.com";
$result =explode('_',file_get_contents($url));
echo $result[1];
$result = ltrim('YES_5e286f3e','YES_');echo $result;
??就可以了。
$url = "http://www.123456.com/Ajax.ashx?Action=AddOrder&OrderIDShow=1&id=10086&Amt=10&Mb=2&Email=fdhfdf@qq.com"; $result = file_get_contents($url); $result = str_replace('YES_', '', $result); // 把YES_替??空echo $result;
把'YES_'替換為空白即可。
參考函數:str_replace();
雖然自己已經找到解決辦法了 不過還是謝謝你們!