PHP Array

Well If you are coming to this topic then am sure that you knows the basics of Array and here am not gona  make you feel bore so lets lets jump start our Concept and Advanced stuffs about an array.

Basic Syntax

1
$arrayName = array("x");

1. PHP array can have key Value pair type

2.Key Value Either in Integer or string , if you provide a float value to key ,php will autometically convert float key to Integer key.

3.If you provide 06 as the key like

1
$arrayName = array(06=>"x");

,Then php will keep the key as 06

4.if you provide 6 as the key like

1
$arrayName = array(6=>"x");

,Then php will keep the key as 6

5.Value of Array can be any type as you wish

7.There is no limitation of adding elements to array.

8.If you wanna be a good programmer so better concerned about Memory leakage while using array with numeric key.

9.Php follow same principle as other programming languages dis, User of memory allocation i.e   if  you add an element to array at key position as 5 , if add another element without specifying the key position then php will take the key position as 6.

 

1.How to Remove elements from an array

Ans: just use the function called

1
unset($arrayName[06]);

2.How many ways we can declare an array

Ans:

1
2
3
4
$arrayName = Array();
$arrayName[] = 1;
${'arrayName'}[] = 1;
$arrayName = explode(",",$stringVariableName);

3.What are the most commonly use 10 Array function that i need to know.

1
2
3
4
5
6
7
8
9
implode
in_array
sizeof
array_intersect
array_sum
is_array
array_diff_assoc
array_reverse
extract