PHP Arrays are a data structure that stores multiple elements of a similar type in a single variable. The arrays are helpful to create a list of elements of similar type. It can be accessed using their index number or key. The array functions are allowed to interact and manipulate the array elements in various ways. The PHP array functions are used for single and multi-dimensional arrays.
Installation: The array functions have not required any installation. These are part of PHP core concepts.
Example: PHP program to sort an array in ascending order using sort() function and print the sorted array.
<?php
// Create an array object
$arr
=
array
(1, 4, 3, 2, 6);
// Sort function to sort
// array elements
sort(
$arr
);
// Prints the sorted array
print_r(
$arr
);
?>
Output:
Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 6 )
You can use implode or Explode for arrays to view indivial strings