What are the types of Array in PHP? Plz, provide an explanation with an example.

Types of PHP Arrays

There are 3 types of arrays in PHP.

  1. Indexed or Numeric Arrays
  2. Associative Arrays
  3. Multi-Dimensional Arrays

Indexed or Numeric Arrays

An index array is an array in which the values or items of the array are assigned by the index number. The name of the index array itself shows that the index number has importance in the index array. The index array has a different index number for each value. Index means 1, 2, 3, 4, 5 but index numbers in the index array start from 0. Index numbers are 0,1,2,3,4,etc.

$var = array("Value0", "Value1", "Value2");


Associative Arrays

The associated array is a simple and very important array of PHP. This array is also used the most, it is also very easy to understand this array, as it contains keys and values. In simple language, the key acts as the name, and the value works as the information related to that name. For Mohan is a key and Mohan’s age or address, email, etc. are his values.



Multi-Dimensional Array

A multidimensional array is an array that uses more than one array, instead of storing a single element, it stores another array at each index.



Related Posts

Associative Array in PHP?

An associative array is a simple and very important array of PHP. This array is also used the most, it is very easy to understand this array,…

How to work in functions PHP?

If there is any task in your program which you train to execute repeatedly then instead of writing the code for that task at a different place…

For Loofs in PHP

In for-loop initialization, condition and increment happen on the same line. The loop keeps on repeating as long as the condition is true. When the for loop…

If Else Conditionals in Php?

If Else statement is the most important feature of any programming language, PHP is used to run any Code Of Block according to If Else conditions. This…

What are operators in PHP? PHP – Operator Types

Operators are used to developing data. In Programming Languages, Operators are taken from Mathematics and Operator Programmers work with Data. An operator is a chain of symbols…

String Functions in PHP?

When many characters are written together in sequence, they form a string. For example, India is a string. It is made up of i, n, d, i,…

0 0 votes
Article Rating
Notify of
Inline Feedbacks
View all comments
Would love your thoughts, please comment.x