$str = "http://wenwen.soso.com/z/ShowTagHighOffer.e?sp=17368320&sp=技能&sp=技能";需要对,后面两个 “&sp=技能&sp=技能” sp 的值进行urlencode编码,如何写?

解决方案 »

  1.   


            $string='http://wenwen.soso.com/z/ShowTagHighOffer.e?sp=17368320&sp=技能&sp=技能';
    $pattern = '/&sp=([^&]*)/';
    preg_match_all($pattern, $string, $match); print_r($match[1]); foreach($match[1] as $v){
    echo urlencode($v);
    echo '<br>';
    }
      

  2.   


    <?php$str = "http://wenwen.soso.com/z/ShowTagHighOffer.e?sp=17368320&sp=技能&sp=技能";$arr=preg_split("/&sp=/",$str);
    echo $arr[1];
    echo $arr[2];?>
    你看这样对不对?