Php array functions

Php array functions with examples

Php array functions is a common array functions. In this Php tips and Tricks, we will look at what an PHP array 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.

What is an PHP arrays?

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:

Saab0 Toyota1 BMW2 Volvo3

Remain that the unique identification number will be start from number 0.

Type of PHP arrays:

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

$cars=array("Saab" , "Toyota" , "BMW" , "Volvo"); 
echo $cars[0] ." and ".$cars[2] ." " ."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:

$families= array ( 
     "Masum"=>array (
echo $families ['Sharif'][0] ." and " .$families ['Masum'][2] ." 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 Php array functions. You can take this as a model.

Tags: php array, php array example,php array functions with examples,php array functions,php array tutorial,php in array

About Masum Billah

Php array functions with examples 1stWebSuite website seo tool is a free website ranking tool site provides a lot of on page and off page seo useful tools for you. On this site, we have a large number of website ranking tools

Discuss about: Php array functions

Newsletter Subscription

Enter your email address:

Delivered by FeedBurner