Php 如何替换数组中的img url
我正在从ulr获取数据,所以现在要更改图像的url,我的代码是Php 如何替换数组中的img url,php,html,curl,Php,Html,Curl,我正在从ulr获取数据,所以现在要更改图像的url,我的代码是 @$domain = $_REQUEST['domain']; function get_dns($url, $curl = true) { $responseString = ''; if (!$curl) { $responseString = file_get_contents($url); } else { $ch = curl_init( $url );
@$domain = $_REQUEST['domain'];
function get_dns($url, $curl = true) {
$responseString = '';
if (!$curl) {
$responseString = file_get_contents($url);
} else {
$ch = curl_init( $url );
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-Type: text/html', 'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36') ,
);
curl_setopt_array( $ch, $options );
$responseString = curl_exec($ch);
}
return $responseString;
}
$url ="http://intodns.scriptburn.com/index.php?domain=$domain";
$query = get_dns($url);
preg_match_all('/<!-- BEGIN CONTENT -->(.*?)<!-- END CONTENT -->/s', $query, $content);
echo $content = $content[0][0];
$url ="http://intodns.scriptburn.com/index.php?domain=$domain";
$query = get_dns($url);
preg_match_all('/<!-- BEGIN CONTENT -->(.*?)<!-- END CONTENT -->/s', $query, $content);
$content = $content[0][0];
$content = preg_replace_callback('~<img\ssrc="static/images/~i',
function($m)
{
return sprintf('<img src="https://www.whoisextractor.in/wp-content/themes/whois/img/', urlencode($m[1]), $m[2], $m[3]);
}, $content);
echo $content;
@$domain=$\u请求['domain'];
函数get_dns($url,$curl=true){
$responseString='';
如果(!$curl){
$responseString=文件获取内容($url);
}否则{
$ch=curl\u init($url);
$options=array(
CURLOPT_RETURNTRANSFER=>true,
CURLOPT_HTTPHEADER=>array('Content-Type:text/html','User-Agent:Mozilla/5.0(Windows NT 6.3;WOW64)AppleWebKit/537.36(KHTML,类似Gecko)Chrome/39.0.2171.95 Safari/537.36'),
);
curl_setopt_数组($ch$options);
$responseString=curl\u exec($ch);
}
返回$responseString;
}
$url=”http://intodns.scriptburn.com/index.php?domain=$domain”;
$query=get_dns($url);
preg_match_all('/(.*?)/s',$query,$content);
echo$content=$content[0][0];
在这里,我想把
替换成最后,我在
现在我的代码是
@$domain = $_REQUEST['domain'];
function get_dns($url, $curl = true) {
$responseString = '';
if (!$curl) {
$responseString = file_get_contents($url);
} else {
$ch = curl_init( $url );
$options = array(
CURLOPT_RETURNTRANSFER => true,
CURLOPT_HTTPHEADER => array('Content-Type: text/html', 'User-Agent: Mozilla/5.0 (Windows NT 6.3; WOW64) AppleWebKit/537.36 (KHTML, like Gecko) Chrome/39.0.2171.95 Safari/537.36') ,
);
curl_setopt_array( $ch, $options );
$responseString = curl_exec($ch);
}
return $responseString;
}
$url ="http://intodns.scriptburn.com/index.php?domain=$domain";
$query = get_dns($url);
preg_match_all('/<!-- BEGIN CONTENT -->(.*?)<!-- END CONTENT -->/s', $query, $content);
echo $content = $content[0][0];
$url ="http://intodns.scriptburn.com/index.php?domain=$domain";
$query = get_dns($url);
preg_match_all('/<!-- BEGIN CONTENT -->(.*?)<!-- END CONTENT -->/s', $query, $content);
$content = $content[0][0];
$content = preg_replace_callback('~<img\ssrc="static/images/~i',
function($m)
{
return sprintf('<img src="https://www.whoisextractor.in/wp-content/themes/whois/img/', urlencode($m[1]), $m[2], $m[3]);
}, $content);
echo $content;
$url=”http://intodns.scriptburn.com/index.php?domain=$domain”;
$query=get_dns($url);
preg_match_all('/(.*?)/s',$query,$content);
$content=$content[0][0];
$Cyp= PrggRePaseTyLeCopRead(‘如果你想用另一个字符串替换一个众所周知的字符串,为什么不使用<代码> StryExchange < /代码>)?还应该考虑使用HTML解析器来代替