Home >> PHP >> Associate array in PHP

Associate array in PHP

Associative array is an array with strings as index. The keys assigned to values and user defined strings.

Example

$age = array("ram"=>"30", "shyam"=>"32", "ravi"=>"34");

 foreach($age as $key => $value) {
        echo "Key=" . $key . ", Value=" . $value;
        echo "<br>";
 }

Output

Key=ram, Value=30
Key=shyam, Value=32
Key=ravi, Value=34

Post Your Comment

Next Questions
Multidimensional array
array() function
array_change_key_case() function
array_chunk() function
array_combine() function
array_count_values() function
array_diff() function
array_diff_assoc() function
array_diff_key() function
array_diff_uassoc() function
array_diff_ukey() function
array_fill() function
array_filter() function
array_flip() function
array_intersect() function
array_intersect_assoc() function
array_intersect_key() function
array_intersect_uassoc() function
array_intersect_ukey() function
array_key_exits() function
array_keys() function
array_map() function
array_merge() function
array_merge_recursive() function
array_multisort() function

Copyright ©2022 coderraj.com. All Rights Reserved.