I would like to convert the array:
Array (  [category] => category  [post_tag] => post_tag  [nav_menu] => nav_menu  [link_category] => link_category  [post_format] => post_format  )   to
array(category, post_tag, nav_menu, link_category, post_format)   I tried
$myarray = 'array('. implode(', ',get_taxonomies('','names')) .')';   which echos out:
array(category, post_tag, nav_menu, link_category, post_format)   So I can do
echo $myarray; echo 'array(category, post_tag, nav_menu, link_category, post_format)';   and it prints the exact same thing.
...but I can't use $myarray in a function in place of the manually entered array because the function doesn't see it as array or something.
What am I missing here?
Associative Array - It refers to an array with strings as an index. Rather than storing element values in a strict linear index order, this stores them in combination with key values. Multiple indices are used to access values in a multidimensional array, which contains one or more arrays.
Your code is the exact equivalent of: $assoc = array_fill_keys(array(1, 2, 3, 4, 5), 1); // or $assoc = array_fill_keys(range(1, 5), 1);
Method 1: Using unset() function: The unset() function is used to unset a key and its value in an associative array. print_r( $arr ); ?> Method 2: Using array_diff_key() function: This function is used to get the difference between one or more arrays.
simply use array_values function:  
$array = array_values($array); 
                        If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With