Site icon Hip-Hop Website Design and Development

How do I take advantage of foreach to get content material from a custom-field in a number of posts?

so I’m attempting to make use of a foreach to tug content material from a {custom} area in a number of posts, but it surely simply wont work. I can get it to work for a easy textarea string however I’m struggling getting it to work for arrays. That is the working code for a string:

$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'submit',));
foreach($posts as $submit)
{
$string = get_post_meta($post->ID, 'simple_string', true);
echo $string;
}

And elsewhere within the web site this code works for stepping into a selected posts {custom} area array:

$arr = get_field('array');
$arr2 = $arr[0]['string'];
$string = implode(", ",$arr2);
echo $string;

Why does not this work?

$posts = get_posts(array(
'numberposts' => -1,
'post_type' => 'submit',));
foreach($posts as $submit)
{
$arr = get_post_meta($post->ID, 'array', true);
$arr2 = $arr[0]['string'];
$string = implode(", ",$arr2);
echo $string;
}

Thanks prematurely for looking.