Array is used to store the collection
of values store by same name and same data type .There are three different kind
of arrays and each array value is access using an ID which is called array
index.
Numeric Array: An Array with numeric index. Values are store and access in linear manner.
Associative Arrays: An array with strings as index. This store element values in Association with key values rather than in a strict linear index order.
There are three type of array
in PHP.
1 Numeric Arrays
2 Associative Arrays
3 Multidimensional ArrayNumeric Array: An Array with numeric index. Values are store and access in linear manner.
Associative Arrays: An array with strings as index. This store element values in Association with key values rather than in a strict linear index order.
Multidimensional Array : An array containing one or more arrays and values are
accessed using multiple indices
Array( ) is used to store the
value in array.
Declaration of Array
<?php
$name=array
(“Raman”,”Deep”,”Pardeep”,”Sapna”,”Neelam”);
echo “my name is”. name [0];
?>
The another way of declaration of array is
<?php
$name=array
(“Raman”,”Deep”,”Pardeep”,”Sapna”,”Neelam”);
echo “my name is”. name [0];
?>
The another way of
declaration of array is
<?php
$color[]=”red”;
$color[]=”green”;
$color[]=”blue”;
$color[]=”white”;
print_r($color);
?>
Array Function
Array Function
Function Name
|
Description
|
Array( )
|
Is used to create array()
|
Array chunk()
|
Splits an array into chunks
of arrays
|
Sort ()
|
This is used to sort the
array
|
Array combine ()
|
Create an array by using
one array for keys and another for its value
|
Array_diff ()
|
Compare array values and
return the difference
|
Array fill()
|
Fills an array with values
|
Asort( )
|
Sort an array and maintain index
association
|
End()
|
Set the internal pointer of
an array to its last element
|
In array( )
|
Checks if a value exists in
an array
|
Shuffle( )
|
Shuffle an array
|
Size of ( )
|
Alias of count
|
Array sum( )
|
Calculate the sum of values
in an array
|
Array reverse
|
Return an array with elements
in reverse order
|
Array replace
|
Replace element from passed
array into first array
|