Limited Time Offer!

For Less Than the Cost of a Starbucks Coffee, Access All DevOpsSchool Videos on YouTube Unlimitedly.
Master DevOps, SRE, DevSecOps Skills!

Enroll Now

Data types in PHP (Array)

In this tutorial we will learn about Array data type in PHP, before that you can see all the data types in PHP given below:

  • String
  • Integer
  • Float
  • Boolean
  • Array
  • Object
  • Null

In PHP we have a special data type where we can assign number of values in single variable using array.

For example: $a = array(10,20,30);

In PHP, there are three types of arrays:

  • Indexed array
  • Associative array
  • Multidimensional array

Indexed array:- PHP indexed array is an array which is represented by an index number by default. All elements of array are represented by an index number which starts from 0. PHP indexed array can store numbers, strings or any object. PHP indexed array is also known as numeric array.

Example:

Output:

We can also use <pre> tag to print both the key and value in the output.

Output:

Another way to write the array in PHP which shows the same output as above:

Joydeep M
Latest posts by Joydeep M (see all)
Tagged : /
0 0 votes
Article Rating
Subscribe
Notify of
guest

0 Comments
Oldest
Newest Most Voted
Inline Feedbacks
View all comments
0
Would love your thoughts, please comment.x
()
x