PHP 从 WordPress 中的元键数组打印变量
我正在尝试从以下数组中打印列表中的“artistName”元键:(
$postID = $post->ID;
$meta = get_post_meta($postID, $_artistMeta->$postID, TRUE);
print_r($meta);
打印以下内容)
Array
(
[_artistMeta] => Array
(
[0] => a:1:{s:10:"artistName";a:2:{i:0;s:33:"la-semilla-de-la-cultura-africana";i:1;s:9:"radiohead";}}
)
)
所以我想打印/回显艺术家姓名(“la-semilla-de-la-cultura-africana”和“radiohead”)...我尝试了以下两个:
foreach ($meta['artistName'] as $artist) {
echo $artist;
}
什么都不打印...或者
foreach ($meta['_artistMeta'] as $artist) {
echo $artist['artistName'];
}
打印“a”。
如果您能帮助我解决这里的语法问题,我将不胜感激! 谢谢!
I'm trying to print the 'artistName' meta keys in a list from the following array:
$postID = $post->ID;
$meta = get_post_meta($postID, $_artistMeta->$postID, TRUE);
print_r($meta);
(which prints the following)
Array
(
[_artistMeta] => Array
(
[0] => a:1:{s:10:"artistName";a:2:{i:0;s:33:"la-semilla-de-la-cultura-africana";i:1;s:9:"radiohead";}}
)
)
So I want to print/echo the artist names ("la-semilla-de-la-cultura-africana" and "radiohead")... I tried the following two:
foreach ($meta['artistName'] as $artist) {
echo $artist;
}
which prints nothing... OR
foreach ($meta['_artistMeta'] as $artist) {
echo $artist['artistName'];
}
which prints "a".
If you can help me with the syntax here, I'd really appreciate it!
Thanks!
如果你对这篇内容有疑问,欢迎到本站社区发帖提问 参与讨论,获取更多帮助,或者扫码二维码加入 Web 技术交流群。
绑定邮箱获取回复消息
由于您还没有绑定你的真实邮箱,如果其他用户或者作者回复了您的评论,将不能在第一时间通知您!
发布评论
评论(1)
你应该使用 unserialize 来取回 php 数组
you should use unserialize to get back a php array