开发者

How to get an array from a saved custom field

I save my array of integers in a custom fields with the func开发者_运维知识库tion:

update_post_meta($post->ID, "images", array(1, 2, 50));

How can I load this array now?

I try to use something like this, but without any luck:

global $post;
$custom = get_post_custom($post->ID);
$myarray = $custom["images"][0];
echo $custom["images"];

It returns something like a:3:{i:0;s:1:"1";i:1;s:1:"2";i:2;s:2:"50";}

May be I can parse this string to get an array from this?


May be I can parse this string to get an array from this?

This is a serialized array.

Use unserialize() to unpack it.

0

上一篇:

下一篇:

精彩评论

暂无评论...
验证码 换一张
取 消

最新问答

问答排行榜