如何在 php-wp 中反序列化数组


how to unserialize array in php-wp?

我正在尝试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。

提供的值无效。如果您尝试反序列化它,您会得到false并注意到:Notice: unserialize(): Error at offset 518 of 2043 bytes .

print_r(false)不打印任何内容,您可以使用var_dump进行更准确的调试