我在这里得到了类似的cookie值
a:3:{i:0;s:2:"87";i:1;s:2:"87";i:2;s:2:"87";}
当我使用cookie时。这里我需要用双引号括起来的值。任何人都可以帮我。
使用unserialize()
<?php
$var='a:3:{i:0;s:2:"87";i:1;s:2:"87";i:2;s:2:"87";}';
print_r(unserialize($var));
输出:
Array
(
[0] => 87
[1] => 87
[2] => 87
)
备用解决方案
<?php
preg_match_all('~"(.*?)"~',
'a:6:{i:0;s:2:"87";i:1;s:2:"87";i:2;s:2:"87";i:3;s:2:"87";i:4;s:2:"88";i:5;s:2:"88";}',
$out, PREG_PATTERN_ORDER);
print_r(($out[0]));
输出:
Array
(
[0] => "87"
[1] => "87"
[2] => "87"
[3] => "87"
[4] => "88"
[5] => "88"
)
试试这个:
$string="a:3:{i:0;s:2:"87";i:1;s:2:"87";i:2;s:2:"87";}";
$its_a_match = preg_match('/"(.+?)"/', $string, $matches);
$whats_inside_the_quotes = $matches[1];