<?PHP $arr=array("apple"=>"carbon","rice"=>"carbon","nuts"=>"fat","meat"=>"protein"); $arr2=array_values($arr); foreach($arr2 as $element) echo "$element, "; //carbon, carbon, fat, protein, ?>
If the parameter array is empty, return an empty array. If the parameter is not an associative array, report ERROR.
<?PHP $arr = array(); $elem = array_values($arr); print_r ($elem); //the result is: Array ( ) ?>
<?PHP $arr=array("apple"=>"carbon","rice"=>"carbon","nuts"=>"fat","meat"=>"protein"); $arr2=array_keys($arr); foreach($arr2 as $element) echo "$element, "; //apple, rice, nuts, meat, ?>