当前位置: 代码迷 >> PHP >> 求指导简化~解决办法
  详细解决方案

求指导简化~解决办法

热度:330   发布时间:2012-04-11 17:42:33.0
求指导简化~
PHP code

<?php 
//调用格式:localhost/getpro.php?userid=slowstang95///
$userid=$_GET["userid"];
$url="http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&userid=".$userid;
$str=file_get_contents($url);

$start='</span></a> <span class="mbg-l"> ( ';
$end='<img src="http://q.ebaystatic';
$content=str_substr($str , $start, $end); 
echo $content; 

function str_substr($str ,$start, $end) { 
    $x = strpos($str, $start); 
    $y = strpos($str, $end);
    $getstr= substr($str,$x+strlen($start),$y-$x);  
    $getstr2=str_replace('<img src="http://q.ebaystatic.com/a',"",$getstr); //!!!
    return $getstr2;
}
?>



------解决方案--------------------
PHP code
$userid=$_GET["userid"];
$url="http://feedback.ebay.com/ws/eBayISAPI.dll?ViewFeedback2&userid=".$userid;
$str=file_get_contents($url);
$pattern='/<span class="mbg-l">\s*\((.*?)<img src="http:\/\/q\.ebaystatic\.com\/a/';
preg_match($pattern,$str,$match);
print_r($match[1]); 
  相关解决方案