$cookie = "csrftoken=P7UBtv3lTNktgrqQglECF7Wj3MWUNJc1; qwqwqwxsewwewe123434dsw4e4d23 qw2323ss";
preg_match('/csrftoken=(.*?);/', $cookie, $matches);//获取匹配的字符串 参数1,规则,2;获取的字符串 3,获得结果集
$csrftoken = $matches[1];
var_dump($matches);
得到:
[ 0 => "csrftoken=P7UBtv3lTNktgrqQglECF7Wj3MWUNJc1;" 1=>"P7UBtv3lTNktgrqQglECF7Wj3MWUNJc1"]