PHP code extracted from ID in Taobao URL

  • 2020-08-22 21:57:03
  • OfStack


<?php
$taobao = 'taobao.com';
$tmall = 'tmall.com';
$guojitmall = 'tmall.hk';
$juhuasuan = 'ju.taobao.com';
/*
 Take the baby's id
 leisure e The family 
*/
function quid($strurl) {
    $strurl = strtolower ( $strurl );
    if (strpos ( $strurl, 'id' ) !== false) {
        $arr = explode ( '?', $strurl );
        $arr = explode ( '&', $arr [1] );
        $NO = 0;
        foreach ( $arr as $k => $v ) {
            if (is_string ( $v )) {
                // Determine whether or not id
                if (strpos ( $v, 'id' ) !== false) {
                    // Dealt with item or num item   return id The number 
                    if (strpos ( $v, 'item' ) !== false || strpos ( $v, 'num' ) !== false) {
                        //echo $v,'<br/>';
                        $i = strrpos ( $v, '=' );
                        $str = substr ( $v, $i + 1 );
                        if (is_numeric ( $str )) {
                            return $NO = $str;
                        }
                    } else {
                        //echo $v,'<br/>';
                        $i = strrpos ( $v, '=' );
                        $str = substr ( $v, $i + 1 );
                        $x = strlen ( $str );
                        if (is_numeric ( $str )) {
                            if ($x ==11) {
                                $NO = $str;
                            } else if ($NO == 0 || ($x > 9 && $x < 11)) {
                                $NO = $str;
                            }
                        }
                    }
                }
            }
        }
        return $NO;
    }
}
?>


Related articles: