我有一个cookie,我试图分割。该cookie的格式如下:如何使用php分割一个cookie
键= VAL1,VAL2,VAL3(其中每一个值是由逗号分隔)
是有办法让我在循环中分裂,这样我可以直接访问VAL3 ?
我试过用explode()函数没有成功。
for ($i = 0; $i < count($_COOKIE); $i++)
{
$ind = key($_COOKIE);
$data = $_COOKIE[$ind];
//I try and slit the cookie here
$cookie_temp = explode(",",$_COOKIE[$ind]);
//Here is where I wanted to display Val3 from the cookie
print $cookie_temp[2];
next($_COOKIE);
}
我的代码能正常工作,但是我最终以大数组结束了我的所有Val3。例如,我的val3是数字,他们被放入一个数组中。我可以进一步分割吗?
“我有一个饼干,我试图分裂。”我可以有一块吗? – 2012-04-08 22:20:59