我在这里得到了cookie值,如
a:3:{i:0;s:2:"87";i:1;s:2:"87";i:2;s:2:"87";}
当我使用cookie时。 在这里,我需要双引号中的值。 任何人帮助我。
答案 0 :(得分:2)
<?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"
)
答案 1 :(得分:0)
试试这个:
$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];