array_keys(input); To get all keys from an array

array_keys();

This function is use to get all keys from a defined variable. The concept will be more clear if we look at an example.

<?php
    $var = array("car"=>"BMW","pen"=>"Econo","brand"=>"Dell");
        echo "<pre>";
        print_r(array_keys($var));
?>

Here $var variable is an array where stored some values and keys. So now if we just want to print only keys on screen. What is the solution ??
Yes...
There is a solution by array_keys(); function. If we input the variable in the function we will get the output.
Then only keys from the array will get out as output.

Comments

Popular posts from this blog

WP register_post_type() with custom CMB2 meta box

Git post receive setup at server for git push to the production from local machine