tags:

views:

12

answers:

1

I save my array of integers in a custom fields with the function:

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?

+2  A: 

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

This is a serialized array.

Use unserialize() to unpack it.

Pekka
Perfect, thanks!
Sergey Basharov