I want to dynamic create an array based on a number inside a multidimensional array
here is the code
$meta_box = array(
\'id\' => \'my-meta-box\',
First you create the array $meta_box as follows:
$meta_box = array(
'id' => 'my-meta-box',
'title' => 'Custom Input Fields',
'page' => 'page',
'context' => 'normal',
'priority' => 'high',
'fields' => array ()
);
Then you can add the 'dynamic' arrays as follows:
$number = 2;
for ($i = 1; $i <= $number; $i++) {
$meta_box['fields'][] = array(
'name' => 'Textarea',
'desc' => 'Enter big text here',
'id' => 'textarea_' . $i, //id is textarea + number
'type' => 'textarea',
'std' => 'Default value'
);
}
This starts the numbering for the ids at 1 until $number.