我最近从一位朋友那里学到了序列化数组,现在一切都有了意义!在解决了这个问题后,它最终在导入方面起到了作用。
以此为例:a:1:{s:7:"address";s:50:"52, St. Michaels Rd,Sheffield,S359YN";}
- a:1: 这是数组大小,此数组中有一条信息为1大小:{键定义;值定义;(每个元素重复)}
- s:7:"address"; 这是值的大小。因此,对于address,单词address中有7个字符,因此值大小为7。
大小:值
还有如下所示的整数值:
i:值
这就是序列化数组中基本上需要担心的所有内容,更正后,wordpress导入器会将这些内容导入到数据库中,而不会出现任何问题,但如果这些内容错误,则会自动转义并将数据库行中的字段留空。
Examples:
String
s:size:value;
Integer
i:value;
Boolean
b:value; (does not store "true" or "false", does store \'1\' or \'0\')
Null
N;
Array
a:size:{key definition;value definition;(repeated per element)}
Object
O:strlen(object name):object name:object size:{s:strlen(property name):property name:property definition;(repeated per property)}
String values are always in double quotes
Array keys are always integers or strings
"null => \'value\'" equates to \'s:0:"";s:5:"value";\',
"true => \'value\'" equates to \'i:1;s:5:"value";\',
"false => \'value\'" equates to \'i:0;s:5:"value";\',
"array(whatever the contents) => \'value\'" equates to an "illegal offset type" warning because you can\'t use an
array as a key; however, if you use a variable containing an array as a key, it will equate to \'s:5:"Array";s:5:"value";\',
and
attempting to use an object as a key will result in the same behavior as using an array will.