Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Prodentim Probiotics Specially Designed For The Health Of Your Teeth And Gums

Instant Grammar Checker - Correct all grammar errors and enhance your writing

Teach Your Child To Read

Powerful WordPress hosting for WordPress professionals

Disclosure: My content contains affiliate links.

31,128 questions

40,777 answers

573 users

How to print array keys from key value array in PHP

2 Answers

0 votes
$array = array('language'=>'PHP', 'code'=>9814, 'level'=>1);
 
$result = array_keys($array);


for ($i = 0; $i < count($result); $i++) {
    echo $result[$i] . "<br />";
}
    
 
 
 
/*
run:
         
language
code
level
       
*/

 





answered Sep 21, 2019 by avibootz
0 votes
$array = array('language'=>'PHP', 'code'=>9814, 'level'=>1);
  
$result = array_keys($array);
 
echo "<pre>";
print_r($result);
echo "</pre>";
     
  
  
  
/*
run:
          
Array
(
    [0] => language
    [1] => code
    [2] => level
)
      
*/

 





answered Sep 21, 2019 by avibootz
edited Sep 21, 2019 by avibootz

Related questions

...