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:
- Laravel 5.8 CRUD operation with example - April 22, 2021
- How to Create Multiple Role Based Authentication in Laravel 5.8 - April 16, 2021
- SQL Queries - April 5, 2021