- Webmaster Tools
- Unblocked Games
Php array functions is a common array functions. In this Php tips and Tricks, we will look at what an is, how it is used, and what it can do. Understanding arrays can be a little difficult in the beginning. But give it a try anyway... we've tried to make it as easy as possible.
An array is a set of indexed elements where each has its own, unique identification number. Sound confusing? It's actually not that complicated. Imagine a list of words separated by commas. It is called a comma-separated list, and it could, for example, look like this:
Saab, Toyota, BMW, Volvo
Then try to imagine dividing the list at each comma. Next, give each section a unique identification number like this:
Remain that the unique identification number will be start from number 0.
PHP array are Three Types such as 1. Numeric array 2. Associative array 3. Multidimensional array
Use of Numeric arrays:
Numeric array saves all array with a numeric index. See the below example of Numeric array
<?php $cars=array("Saab" , "Toyota" , "BMW" , "Volvo"); echo $cars ." and ".$cars ." " ."are my favorite cars"; ?>
Result: Saab and BMW are my favorite cars If you want to display other cars by adding $cars[here your array numeric id]
Use of Associative array:
<?php $age= array("Masum"=>24, "Apu"=>23, "Shimul"=>22); echo "Masum is " . $age[Masum] . " years old"; ?>
Result : Masum is 24 years old Here $age[Masum] is Calling Masum =>24 from the above array.
Use of Multidimensional array:
<?php $families= array ( "Masum"=>array ( "Apu", "Sayed", "Shimul", ), "Munirul"=>array( "Hasan", ), "Sharif"=>array( "Rony", "Moin", "Rubai", ), ); echo $families ['Sharif'] ." and " .$families ['Masum'] ." come from different Family."; ?>
Result : Rony and Shimul come from different Family. Here I have used multidimensional array. Actually it is used for getting array within array. Now you should practice more and more with . You can take this as a model.