bidvertiser

Monday, September 8, 2008

PHP Contents

Data Types & Variable Declarations.
•Data Types.
–integer, float, boolean, string, array, object, resource, NULL
•Variable Declarations.
–$variablename = ;
–$anothervariable =& $variablename; (Assign by Reference)
•Array Declarations.
–$arrayname = array();

More on arrays.
$a[0] = "abc";
$a[1] = "def";
$b["foo"] = 13; (Associative subscript).
You can also create an array by simply adding values to the array.
When you assign a value to an array variable using empty brackets, the value will be added onto the end of the array.
$a[] = "hello"; // $a[2] == "hello"
$a[] = "world"; // $a[3] == "world"

Double dimension arrays.
$arr[2][3] = array();
$arr[0][0] = 34;

Array Functions.
•sort(); (Sort array assigns new keys)
•asort(); (Sort array maintain keys)
•rsort(); (Sort array in reverse, new keys)
•arsort(); (Sort array in reverse, maintain keys)
•count(); (Count elements)
•count(,COUNT_RECURSIVE); (Count multidimensional array)
•array_push(,); (Push item onto end of array)
•array_pop(); (Pop item off end of array)

No comments: