如何使用爆炸?
所以我有这个 php:
<?php
if (isset($_COOKIE["currentsearchctrl"])) {
$cookz = $_COOKIE["currentsearchctrl"];
$data = explode(';', $cookz, -1);
$newdata = array();
foreach($data as $value){
$newdata[] = explode(':', $value, -1);
}
print_r($newdata);
} else { }
?>
php 正在读取的 cookie:
%20Rod%20Stewart%20%3A%2059088763306%3B%20Led%20Zeppelin%20Official%20%3A%20131572223581 891%3B%20Lynrd%20Skynyrd%20%3A%206983887641%3B%20Black%20Sabbath%20%3A%2056848544614%3B
但“print_r”正在输出:
Array ( [0] => Array ( [0] => Rod Stewart ) [1] => Array ( [0] => Led Zeppelin Official ) [2] => Array ( [0] => Lynyrd Skynyrd ) [3] => Array ( [0] => Black Sabbath ) )
“id”丢失。我需要它。 Array([0] => Array ([0] => 罗德·斯图尔特, [1] => 1200420 ) [1] => Array ( [0] => 齐柏林飞船官方, [1] => ; 110024294 )...
为了提供帮助,这是 print_r($data) 的输出:
Array ( [0] => Rod Stewart : 59088763306 [1] => Led Zeppelin Official : 131572223581891 [2] => Lynyrd Skynyrd : 6983887641 [3] => Black Sabbath : 56848544614 )
有人可以帮忙吗?
So i have this php:
<?php
if (isset($_COOKIE["currentsearchctrl"])) {
$cookz = $_COOKIE["currentsearchctrl"];
$data = explode(';', $cookz, -1);
$newdata = array();
foreach($data as $value){
$newdata[] = explode(':', $value, -1);
}
print_r($newdata);
} else { }
?>
The cookie that is being read by php:
%20Rod%20Stewart%20%3A%2059088763306%3B%20Led%20Zeppelin%20Official%20%3A%20131572223581891%3B%20Lynyrd%20Skynyrd%20%3A%206983887641%3B%20Black%20Sabbath%20%3A%2056848544614%3B
but the 'print_r' is outputting:
Array ( [0] => Array ( [0] => Rod Stewart ) [1] => Array ( [0] => Led Zeppelin Official ) [2] => Array ( [0] => Lynyrd Skynyrd ) [3] => Array ( [0] => Black Sabbath ) )
The 'id' is missing. I needed it to be. Array([0] => Array ([0] => Rod Stewart, [1] => 1200420 ) [1] => Array ( [0] => Led Zeppelin Official, [1] => 110024294 )...
To help, this is the output of print_r($data):
Array ( [0] => Rod Stewart : 59088763306 [1] => Led Zeppelin Official : 131572223581891 [2] => Lynyrd Skynyrd : 6983887641 [3] => Black Sabbath : 56848544614 )
Could someone help?
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。

绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(3)
我认为这就是你想要做的:
输出
I think this is what you're trying to do:
Output
为什么不尝试使用正则表达式呢?
编辑:抱歉,我没有注意到名称不完整
示例:preg_match_all
Why don't you try with regular expressions?
EDIT: Sorry I didn't notice the name wasn't complete
Example: preg_match_all
使用serialize()和unserialize()
序列化字符串可确保将精确的结构存储到字符串中以便稍后恢复。
use serialize() and unserialize()
Serializing string ensures that you store exact structire into the string to be later recovered.