1 <?php 2 $taobao = 'taobao.com'; 3 $tmall = 'tmall.com'; 4 $guojitmall = 'tmall.hk'; 5 $juhuasuan = 'ju.taobao.com'; 6 7 /* 8 取宝贝的id 9 10 休闲e族 11 12 */ 13 function quid($strurl) { 14 $strurl = strtolower ( $strurl ); 15 if (strpos ( $strurl, 'id' ) !== false) { 16 $arr = explode ( '?', $strurl ); 17 $arr = explode ( '&', $arr [1] ); 18 $NO = 0; 19 foreach ( $arr as $k => $v ) { 20 if (is_string ( $v )) { 21 //判断是否含有id 22 if (strpos ( $v, 'id' ) !== false) { 23 //处理含有item或者num项 返还id数 24 if (strpos ( $v, 'item' ) !== false || strpos ( $v, 'num' ) !== false) { 25 //echo $v,'<br/>'; 26 $i = strrpos ( $v, '=' ); 27 $str = substr ( $v, $i + 1 ); 28 if (is_numeric ( $str )) { 29 return $NO = $str; 30 } 31 } else { 32 //echo $v,'<br/>'; 33 $i = strrpos ( $v, '=' ); 34 $str = substr ( $v, $i + 1 ); 35 $x = strlen ( $str ); 36 if (is_numeric ( $str )) { 37 if ($x ==11) { 38 $NO = $str; 39 } else if ($NO == 0 || ($x > 9 && $x < 11)) { 40 $NO = $str; 41 } 42 } 43 } 44 } 45 } 46 } 47 return $NO; 48 } 49 } 50 ?>