看了一整天的教程求大神帮忙。
$a = ***如果
$a 的域名是youku.com则替换成我想要的内容1并显示.
$a 的域名是qq.com则替换成我想要的内容2并显示.
下面是我找的类似的代码但是怎么改也不对,求大神帮忙改改。
function get_type($str){
$type=array("youku"=>"youku.com","tudou"=>"tudou.com","56"=>"56.com","ku6"=>"ku6.com","sohu"=>"sohu.com");
foreach ($type as$k=>$v){
if(istype($v,$str))
return $k;
}
 return 0;
}
function istype($key,$str){
  return preg_match("/".$key."/i",$str,$match);
  }
function get_embed($type,$str,$width,$height){
switch($type){
case 'youku':
$vid1=explode("sid/",$str);
$vid2=explode("/v.swf",$vid1[1]);
$vid=$vid2[0];
return '<iframe height="'.$height.'" width="'.$width.'" src="http://player.youku.com/embed/'.$vid.'" frameborder=0 allowfullscreen></iframe>';break;
case 'tudou':
$vid1=explode("]",$str);
$vid2=explode("[",$vid1[1]);
$vid=$vid2[0];
return '<embed src="'.$vid.'" type="application/x-shockwave-flash" allowscriptaccess="always" allowfullscreen="true" wmode="opaque" width="'.$width.'" height="'.$height.'"></embed>';break;
case '56':
$vid1=explode("v_",$str);
$vid2=explode(".swf",$vid1[1]);
$vid=$vid2[0];
return '<iframe width="'.$width.'" height="'.$height.'" src="http://www.56.com/iframe/'.$vid.'" frameborder="0" allowfullscreen=""></iframe>';break;
case 'ku6':
$vid1=explode("/v.swf",$str);
$vid2=explode("/",$vid1[0]);
$len=count($vid2)-1;
$vid=$vid2[$len];
return '<embed src="http://player.ku6.com/refer/'.$vid.'/v.swf" width="'.$width.'" height="'.$height.'" allowscriptaccess="always" allowfullscreen="true" type="application/x-shockwave-flash" flashvars="from=ku6"></embed>';break;
case 'sohu':
$vid1=explode("/v.swf",$str);
$vid2=explode("/",$vid1[0]);
$len=count($vid2)-1;
$vid=$vid2[$len];
return '<embed width='.$width.' height='.$height.' wmode="Transparent" allowfullscreen="true" allowscriptaccess="always" quality="high" src="http://share.vrs.sohu.com/'.$vid.'/v.swf" type="application/x-shockwave-flash"/></embed>';break;
}

}

解决方案 »

  1.   

    如果
    $a 的域名是youku.com则替换成我想要的内容1并显示.
    $a 的域名是qq.com则替换成我想要的内容2并显示没有看到$a。没看懂你要实现什么功能。
      

  2.   

    你需要的不是别人指出问题在哪,而是需要最基本的调试技巧
    对所有变量一个一个var_dump或者print_r打印出变量的值
    然后看看和自己希望的值是否一致,找到产生不一致的地方
    如果是函数就查阅一下文档看看函数的特性什么的