Array in PHP?
Array in PHP
Array
- It is used to store sequential data.
- It has a linear Data Structure.
- The data is organized in a linear order in which elements are linked one after the other.
- It takes the memory in a sequential manner to store the data.
- Array data can be received by index and the index of the array can be started with zero by default.
- In PHP you can also assign your index with value in array using '=>' operator.
Now, there are two syntaxes to use array in PHP
- array();
- [];
Examples -:
- $array_name = array(10, 20, 30);
- $array_name = [10, 20, 30];
Explain the working of Array in PHP -:
- The index of array can be start with zero if you can want to assign index then -: $array_name = ['first'=>10, 'second'=>20, 30];
NOTE -: If you can declare an array with index then you can access this array value with your index if you can't declare index then by default index will start with zero.
Example -: $array_name = ['first'=>10, 'second'=>20, 30];
No comments