Associative Array in PHP – website development

In this video

This tutorial is about Associative Array in PHP. In our last lecture we learned about Indexed Array in PHP. If you haven’t watched it yet then here is the link of tutorial

Associative Array in PHP

In this tutorial we will learn about Associative Array in PHP. The associative arrays are very similar to numeric arrays in term of functionality but they are different in terms of their index. Associative array will have their index as string, so that you can establish a strong association between key and values.

Associative arrays are arrays that use named keys that you assign to them.

NOTE − don’t keep associative array inside double quote while printing otherwise it would not return any value.

Create Associative Array

There are two ways to create an associative array:

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


$age[‘Peter’] = “35”;

$age[‘Ben’] = “37”;

so these are two ways to create indexes array , so code for first method is here.


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

echo “Peter is ” . $age[‘Peter’] . ” years old.”;


Output: Peter is 35 years old.

Associative Array in PHP tutorial end here. If you have any queries you can ask us on our Facebook page link is given below, Thank you for watching us.


Tutorial Hive’s mission is to provide quality education to all our community. Tutorial Hive’s mission is to provide free education to all those who cannot afford BIG FEE of institutes. We aim specifically to empower youth to understand programming related knowledge which further helps the society to reduce complex problems through applications. Why Tutorial Hive? We not only provide the theoretical knowledge but also provide the actual implementation with working sample applications. Tutorial Hive cannot achieve its mission without the help of our community. So, please if you think you can help in any manner feel free to contact us. Or if you see any mistake in our content which can be modified/corrected then please leave us a message

We are always open for suggestions.


Subscribe on YouTube:

Follow us on Social Media

You might be interested in


Your email address will not be published. Required fields are marked *