gpt4 book ai didi

php - 这个编码叫什么?

转载 作者:可可西里 更新时间:2023-11-01 00:35:01 24 4
gpt4 key购买 nike

我在 Wordpress 的数据库中看到它,现在我在 cookie 中看到类似的东西。什么样的解析器解析这个:

a:4:{s:14:"clientsorderby";s:9:"firstname";s:12:"clientsorder";s:4:"DESC";s:13:"ordersorderby";s:2:"id";s:11:"ordersorder";s:4:"DESC";}

我明白了,它是 a=array:x=number of children s=string:x=number of characters.

PHP 中是否内置了用于此类操作的解析器?他们为什么使用这种方法?

最佳答案

是PHP内置的serialize() ,可以用unserialize()“解码”

这是一个例子:

$serialized = 'a:4:{s:14:"clientsorderby";s:9:"firstname";s:12:"clientsorder";s:4:"DESC";s:13:"ordersorderby";s:2:"id";s:11:"ordersorder";s:4:"DESC";}';
$unserialized = unserialize( $serialized);

var_dump( $unserialized);

输出:

array(4) {
["clientsorderby"]=>
string(9) "firstname"
["clientsorder"]=>
string(4) "DESC"
["ordersorderby"]=>
string(2) "id"
["ordersorder"]=>
string(4) "DESC"
}

关于php - 这个编码叫什么?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/10891281/

24 4 0
Copyright 2021 - 2024 cfsdn All Rights Reserved 蜀ICP备2022000587号
广告合作:1813099741@qq.com 6ren.com