Coding Villa

Get all keys & values from array using array_keys, array_values in PHP

Author : Tahreem Anwar

Share with Friends
Views : 368
Ratings : 0
Bookmarks : 0
Farourities : 0

Description


In this simple article you will learn about the method to get all keys & values from array using array_keys, array_values in PHP.


Advertisements


 

 

Code:

 

<?php

$name["T"]="Tahreem";

$name["R"]="Rizwan";

$name["F"]="Fatima";

$name["M"]="Misbah";

print_r(array_keys($name));

?>

 

Output:

 

Array ( [0] => T [1] => R [2] => F [3] => M )

 

Explanation:

 

In the above code we have declared $name array type variable and initialize it by index. First index name T has value Tahreem. Second index name R have value Rizwan. Third index name F have value Fatima. Fourth index name M have value Misbah. Then pass that array to array_keys function of php that returns all the keys of array. For example in the above code output 0=>T means ‘0’ index name is T and 1=>R means ‘1’ index name is R.

 



Article Tags
Share with Friends

Comments




Leave a Reply

Name (required)  
Mail (will not be published) (required)   
 
Enter This Code
Captcha
 

Advertisements

Article Categories

.NET


Databases


Mobile Development


Operating Systems


Web Development


Coding Villa on Facebook