What is PHP array and its types | PHP lecture 37 | How to do this

Опубликовано: 23 Октябрь 2024
на канале: arbn Studios
243
10

What is PHP array and its types, PHP Arrays, Arrays Function in PHP, Array Types with example
#WhatIsPHPArrayAndTtsTypes, #ArraysFunctionInPHP,#HowToDoThis


PHP array is an ordered map (contains value on the basis of key). It is used to hold multiple values of similar type in a single variable.
PHP Array Types

There are 3 types of array in PHP.
1- Indexed Array
2- Associative Array
3- Multidimensional Array


PHP Indexed Array
PHP index is represented by number which starts from 0. We can store number, string and object in the PHP array. All PHP array elements are assigned to an index number by default.
$season=array("summer","winter","spring","autumn");



PHP Associative Array:
We can associate name with each array elements in PHP


PHP Multidimensional Array:
PHP multidimensional array is also known as array of arrays. It allows you to store tabular data in an array. PHP multidimensional array can be represented in the form of matrix which is represented by row * column.


PHP Array Functions:
PHP provides various array functions to access and manipulate the elements of array. The important PHP array functions are given below.


PHP array() function:
PHP array() function creates and returns an array. It allows you to create indexed, associative and multidimensional arrays.


PHP count() function:
PHP count() function counts all elements in an array.


PHP sort() function:
PHP sort() function sorts all the elements in an array.


PHP array_reverse() function:
PHP array_reverse() function returns an array containing elements in reversed order.


PHP array_search() function:
PHP array_search() function searches the specified value in an array. It returns key if search is successful.