Professional Documents
Culture Documents
Part II
Chapter 19: PHP part 2
By: Eyad Alshareef
Eyad Alshareef
Eyad Alshareef
Eyad Alshareef
Eyad Alshareef
Eyad Alshareef
Eyad Alshareef
Eyad Alshareef
Eyad Alshareef
Eyad Alshareef
Eyad Alshareef
Array definition
Element By Element
$A[0] = 3; $A[1]=7; $A[]=5;
Array function
$B = array (3,7,5);
$C = array(blue , red);
to iterate through array elements
for($i =0 ; $i < count ($A) ; $i++)
print (index $i has value $A[$i]);
Eyad Alshareef
Outline
arrays.php
Automatically creates
array $first
(1 of 4)
Eyad Alshareef
24
25
Outline
</strong><br />" );
26
27
28
arrays.php
29
30
31
32
33
34
(2 of 4)
Function array
creates array
$second with its
indices
arguments as elements
Creates
associative array
$third
35
36
37
38
39
40
41
42
43
44
45
Moves the
internal pointer to
the next element
and returns it
46
47
Outline
</strong><br />" );
48
49
50
// string indices
51
$fourth = array(
52
"January"
=> "first",
53
"March"
=> "third",
"April"
=> "fourth",
54
"May"
=> "fifth",
"June"
=> "sixth",
55
"July"
56
57
"November"
58
);
arrays.php
"October"
=> "eighth",
=> "tenth",
59
60
61
62
63
64
(3 of 4)
</body>
65 </html>
Iterates through
each element in
array $fourth
Eyad Alshareef
Stores
the
index of
the
element