Do You Know How to Use Associative Arrays in PHP - Coding Cyber

Do You Know How to Use Associative Arrays in PHP

Do You Know How to Use Associative Arrays in PHP

Other Articles in PHP Advanced Data Types Section

Quickly Navigate to Other Sections in PHP Tutorials

PHP Basics
PHP Data Types
PHP Advanced Data Types
PHP Logical Statements
PHP Operators
PHP Loops
User Defined Functions in PHP
Useful PHP Functions

This is an example code for Associative array. In this type of array, we will add pocket key and value. And whenever we want to access them, we can do it by based on the array key. Array key is name of the person and the array value is age of that person.

$age = array(“Peter”=>”35”, “Ben”=>”37”, “Joe”=>”43”);

foreach($age as $x => $x_value) {
echo “Key=” . $x . “, Value=” . $x_value;
echo “
“;
}

Related Posts
No related posts for this content
Vivek Vengala
 

Vivek Vengala is a Online Entrepreneur, Web Developer from Hyderabad India.

Click Here to Leave a Comment Below 0 comments

Leave a Reply: