gpt4 book ai didi

mysql - 是否有存储数据的名称,其中每行都有一个分号或花括号?

转载 作者:行者123 更新时间:2023-12-01 00:48:46 26 4
gpt4 key购买 nike

我试图了解 Wordpress 插件如何处理数据,当我从 MySQL 中提取它时,结果如下:

a:1:{s:9:"home-team";a:6:{s:2:"id";s:9:"home-team";s:4:"slug";s:9:"home-team";s:4:"type";s:6:"select";s:4:"name";s:9:"Home Team";s:11:"description";s:0:"";s:4:"data";a:4:{s:7:"options";a:3:{s:60:"wpcf-fields-select-option-3892e2c3ad45e24dc7f47ff2ba880c33-2";a:2:{s:5:"title";s:13:"Chicago Bears";s:5:"value";s:1:"1";}s:60:"wpcf-fields-select-option-09fbd82bfa4142df6439c8e15d96dbfc-1";a:2:{s:5:"title";s:15:"New York Giants";s:5:"value";s:1:"2";}s:60:"wpcf-fields-select-option-7c7df972f933545b37c41ca249c686b4-1";a:2:{s:5:"title";s:15:"Oakland Raiders";s:5:"value";s:1:"3";}}s:8:"validate";a:1:{s:8:"required";a:3:{s:6:"active";s:1:"1";s:5:"value";s:4:"true";s:7:"message";s:22:"This Field is required";}}s:19:"conditional_display";a:2:{s:8:"relation";s:3:"AND";s:6:"custom";s:0:"";}s:16:"disabled_by_type";i:0;}}}

存储方式有名称吗?对我来说,它看起来有点像 JSON,但这当然不是 JavaScript。另外,有没有办法轻松清理它(通过使用在线工具),所以前几行看起来像这样:

a:1: {
s:9:"home-team";
a:6: {
s:2:"id";
s:9:"home-team";
s:4:"slug";
s:9:"home-team";
s:4:"type";
s:6:"select";
s:4:"name";

等等......等等......

最佳答案

这是 PHP 序列化格式。

参见:http://php.net/manual/en/function.serialize.php

不确定如何获得与您拥有的完全一样的格式化版本(但您可能可以轻松地将它们放在一起),但这是了解序列化字符串中内容的另一种方法:

$test_string= 'a:1:{s:9:"home-team";a:6:{s:2:"id";s:9:"home-team";s:4:"slug";s:9:"home-team";s:4:"type";s:6:"select";s:4:"name";s:9:"Home Team";s:11:"description";s:0:"";s:4:"data";a:4:{s:7:"options";a:3:{s:60:"wpcf-fields-select-option-3892e2c3ad45e24dc7f47ff2ba880c33-2";a:2:{s:5:"title";s:13:"Chicago Bears";s:5:"value";s:1:"1";}s:60:"wpcf-fields-select-option-09fbd82bfa4142df6439c8e15d96dbfc-1";a:2:{s:5:"title";s:15:"New York Giants";s:5:"value";s:1:"2";}s:60:"wpcf-fields-select-option-7c7df972f933545b37c41ca249c686b4-1";a:2:{s:5:"title";s:15:"Oakland Raiders";s:5:"value";s:1:"3";}}s:8:"validate";a:1:{s:8:"required";a:3:{s:6:"active";s:1:"1";s:5:"value";s:4:"true";s:7:"message";s:22:"This Field is required";}}s:19:"conditional_display";a:2:{s:8:"relation";s:3:"AND";s:6:"custom";s:0:"";}s:16:"disabled_by_type";i:0;}}}';
$unser = unserialize( $test_string);
print_r ( $unser );

将显示:

Array
(
[home-team] => Array
(
[id] => home-team
[slug] => home-team
[type] => select
[name] => Home Team
[description] =>
[data] => Array
(
[options] => Array
(
[wpcf-fields-select-option-3892e2c3ad45e24dc7f47ff2ba880c33-2] => Array
(
[title] => Chicago Bears
[value] => 1
)

[wpcf-fields-select-option-09fbd82bfa4142df6439c8e15d96dbfc-1] => Array
(
[title] => New York Giants
[value] => 2
)

[wpcf-fields-select-option-7c7df972f933545b37c41ca249c686b4-1] => Array
(
[title] => Oakland Raiders
[value] => 3
)

)

[validate] => Array
(
[required] => Array
(
[active] => 1
[value] => true
[message] => This Field is required
)

)

[conditional_display] => Array
(
[relation] => AND
[custom] =>
)

[disabled_by_type] => 0
)

)

)

关于mysql - 是否有存储数据的名称,其中每行都有一个分号或花括号?,我们在Stack Overflow上找到一个类似的问题: https://stackoverflow.com/questions/18337499/

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