我正在尝试get_post_meta($post_id,'meta_key_here',true);
在我的数据库中,meta_key包含值
- >
a:3:{i:0;a:4:{s:5:"title";s:10:"Directions";s:2:"id";s:14:"tab-directions";s:7:"content";s:422:"<strong>Custom fields </strong> can be used to add extra metadata to a post that you can use in your theme.
<ul>
<li>Custom fields can be used to add extra metadata to a post that you can use in your theme.</li>
<li>Custom fields can be used to add extra metadata to a post that you can use in your theme.</li>
<li>Custom fields can be used to add extra metadata to a post that you can use in your theme.</li>
</ul>";s:15:"tooltip_content";s:13:"tooltip dataa";}i:1;a:4:{s:5:"title";s:18:"Directions for use";s:2:"id";s:22:"tab-directions-for-use";s:7:"content";s:736:"<strong>Custom fields </strong> can be used to add extra metadata to a post that you can use in your theme.
<ul>
<li>Custom fields can be used to add extra metadata to a post that you can use in your theme.</li>
<li>Custom fields can be used to add extra metadata to a post that you can use in your theme.</li>
<a href=""><strong>Custom fields </strong> can be used to add extra metadata to a post that you can use in your theme.
<ul>
<li>Custom fields can be used to add extra metadata to a post that you can use in your theme.</li>
<li>Custom fields can be used to add extra metadata to a post that you can use in your theme.</li>
Custom fields can be used to add extra metadata to a post that you can use in your theme. </a>";s:15:"tooltip_content";s:15:"tooltip dataa 2";}i:2;a:4:{s:5:"title";s:25:"super charged ingredients";s:2:"id";s:29:"tab-super-charged-ingredients";s:7:"content";s:413:"<strong>Custom fields </strong> can be used to add extra metadata to a post that you can use in your theme.
<ul>
<li>Custom fields can be used to add extra metadata to a post that you can use in your theme.</li>
<li>Custom fields can be used to add extra metadata to a post that you can use in your theme.</li>
<li>Custom fields can be used to add extra metadata to a post that you can use in your theme.</li>";s:15:"tooltip_content";s:15:"tooltip dataa 3";}}
当我尝试这个时
`$my_data=unserialize($data);
print_r($my_data);`
它什么也没显示。(空数组)。 (我想从这个序列化数组中获取特定postid的tooltip_content。)
答案 0 :(得分:0)
提供的值无效。如果您尝试对其进行反序列化,则会获得false
并注意:Notice: unserialize(): Error at offset 518 of 2043 bytes
。
且print_r(false)
无法打印任何内容,您可以使用var_dump
进行更准确的调试