【发布时间】:2021-08-12 14:54:37
【问题描述】:
我正在尝试使用 Wordpress 中的函数将序列化数据输出到使用 WP All Export 的电子表格中。它已成功对其进行反序列化,但是在我需要的所需部分下缺少数据。
函数如下:
<?php
function data_deserialize($value){
$output = '';
$data = maybe_unserialize($value);
$data = $data[0];
foreach ($data as $key => $value){
$output .= $key.': '.$value.'
';
}
return $output;
}
?>
以下序列化数据正在作为 $value 输出。
a:1:{i:0;a:9:{s:16:"tmcp_post_fields";a:2:{s:12:"tmcp_radio_0";s:11:"Test Card_9";s:15:"tmcp_textarea_1";s:19:"This is the message";}s:10:"product_id";i:934;s:19:"per_product_pricing";b:1;s:17:"cpf_product_price";s:2:"15";s:12:"variation_id";s:4:"1030";s:11:"form_prefix";s:0:"";s:20:"tc_added_in_currency";s:3:"GBP";s:19:"tc_default_currency";s:3:"GBP";s:14:"tmcartepo_data";a:2:{i:0;a:2:{s:3:"key";s:11:"Test Card_9";s:9:"attribute";s:12:"tmcp_radio_0";}i:1;a:2:{s:3:"key";s:19:"This is the message";s:9:"attribute";s:15:"tmcp_textarea_1";}}}}
但是函数的输出会导致电子表格中出现这种情况
tmcp_post_fields: Array
product_id: 934
per_product_pricing: 1
cpf_product_price: 15
variation_id: 1030
form_prefix:
tc_added_in_currency: GBP
tc_default_currency: GBP
tmcartepo_data: Array
如您所见,它缺少 tmcp_post_fields 下的数据,这实际上是我需要导出到电子表格的数据。
实现这一目标我缺少什么?
非常感谢
【问题讨论】:
标签: php wordpress serialization wpallimport