I' am currently stuck in a issue where merged array only showing first array on dump. Attached is the image of the dump.
As you can see the first (index 0) array comes out really well, but the second and third array are not in correct array format.
This function appends array to $add_admin_menu variable
$add_admin_menu = array();
function add_admin_menu( $args ) {
global $add_admin_menu;
if( !empty($add_admin_menu) ){
$arg1 = $add_admin_menu;
return $add_admin_menu = array_merge($arg1, $args);
} else {
return $add_admin_menu = array($args);
}
}
This function just calls the variable $add_admin_menu and makes it into a function
function get_admin_menu(){
global $add_admin_menu;
return $add_admin_menu;
}
**This is how I call the function add_admin_menu and pack array inside it **
$args1 = array("Dashboard", "dashboard.php", "dashboard");
add_admin_menu($args1);
$args2 = array("Posts", "posts.php", "posts");
add_admin_menu($args2);
$args3 = array("Pages", "pages.php", "pages");
add_admin_menu($args3);
$get_admin_menu = get_admin_menu();
echo "<pre>";
print_r( $get_admin_menu );
echo "</pre>";
if( !empty($add_admin_menu) ){ $arg1 = $add_admin_menu; array_push($add_admin_menu, $args); }