-2

这是我的代码,

$menu_name = 'featured-page'; // Name of Custom Navagation in the back end

if ( ( $locations = get_nav_menu_locations() ) && isset( $locations[ $menu_name ] )) {
    $menu = wp_get_nav_menu_object( $locations[ $menu_name ] );
    $menu_items = wp_get_nav_menu_items($menu->term_id);
}

foreach ( $menu_items as $menu_item ) {
  $numbers[] = get_post_meta( $menu_item->ID, '_menu_item_object_id', true );
}

var_dump($numbers) ;

var_dump($numbers) ;

会显示这个

数组(3) { [0]=> 字符串(2) "11" [1]=> 字符串(1) "9" [2]=> 字符串(1) "8" }

我需要打印出来

11,9,8

如何才能做到这一点?

4

1 回答 1

0

使用内爆

echo implode(',', $numbers);
于 2013-04-13T23:00:50.650 回答