Creating Arrays

array() and var_dump

array(7) { [0]=> string(6) "violet" [1]=> string(6) "indigo" [2]=> string(4) "blue" [3]=> string(5) "green" [4]=> string(6) "yellow" [5]=> string(6) "orange" [6]=> string(3) "red" }

It dumps the arry on to the page, it shows how many things in the array, how many values (ie letters numbers) are in each part and the index of each


Array ( [0] => violet [1] => indigo [2] => blue [3] => green [4] => yellow [5] => orange [6] => red [7] => Gray )
Array
violet
Gray

Print gives some informating like index while dump gives you more like if its a string and how many in the array

array() and print_r

Array ( [0] => 1 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 6 [6] => 7 [7] => 8 [8] => 9 )
Array ( [0] => 10 [1] => 2 [2] => 3 [3] => 4 [4] => 5 [5] => 5 [6] => 7 [7] => 8 [8] => 9 [9] => 0 )

It dumps out the array and shows each value in the array with the index

associative array

Array ( [IT 1430] => Web Page Development [IT 3132] => Web Programming [IT 5233] => Web and Mobile Security Fundamentals [IT 5236] => Mobile Web Infrastructure )
Web and Mobile Security Fundamentals
Web Programming

array count function

10
8
4

for loop

violet
indigo
blue
green
yellow
orange
red
Gray

foreach...as loops

10
2
3
4
5
5
7
8
9
0
IT 1430 is Web Page Development
IT 3132 is Web Programming
IT 5233 is Web and Mobile Security Fundamentals
IT 5236 is Mobile Web Infrastructure