PHP

Cookie字符串转数组

public function setCookieString($string){
    $result = array();
    if(preg_match_all('/\s*([^;=]+)=([^;]+)/i',$string,$matches) > 0){
        if(isset($matches[1]) && isset($matches[2])){
            if(count($matches[1]) == count($matches[2])){
                foreach ($matches[1] as $handle => $key) {
                    $result[$key] = $matches[2][$handle];
                }
            }
        }
    }
    return $result;
}


评论 0

还没有评论,来说两句吧。

验证码

登录后即可评论。评论需要填写验证码。