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 pluginsmeta-boxincfieldsselect.php on line 132
how I can use it?
any solution accepted.
thanks.
You could try this:
Your array is not written in the correct PHP syntax, so that’s most likely the error you’re receiving.
There’s a nice explanation here in the PHP manual on how to construct arrays .
But you should also consider the
add_theme_support()
advice suggested in the comments, if you’re setting up multiple post formats.It will give a radio box like this one.
See for example this description.
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
Its not logical error, its from your syntax.
Check your syntax from foreach.