phpwordpresshtml-selectmeta-boxes

meta box plugin use php array as select options?


I have PHP array

$my_array=Array
(
  [0] => standard
  [1] =>  aside
  [2] =>  image
  [3] =>  gallery
  [4] =>  video
  [5] =>  status
  [6] =>  quote
  [7] =>  link
  [8] =>  chat
  [9] =>  audio
 );

I want to use it as meta-box plugin select options

 array(
    'name' =>  __( 'Select', 'rwmb' ),
    'id'   => "{$prefix}page_icon",
    'type'     => 'select',
    'options'  => $my_array,
    'multiple'    => false,
    'placeholder' => __( 'Select an Item', 'rwmb' ),
 ),

It give me error.

Warning: Invalid argument supplied for foreach() in plugins\meta-box\inc\fields\select.php on line 132

how I can use it? any solution accepted. thanks.


Solution

  • See where you declare array

    it's may be out of function

    or inside of other function

    try to declare it in function or make array global