<?php
error_reporting(E_ALL);
//this is an index array
$variable = array(2,3,8,9);
echo $variable[0];
echo '<br>';
echo $variable[1];
echo '<br>';
echo $variable[2];
echo '<br>';
echo $variable[3];
echo '<br>';
//use while loops or for loops for this type of array.
//while loop:
echo "WHILE LOOP!<br>";
$i=0;
while ($i<=count($variable)){
	echo "i is ".$i.' and the value is '.$variable[$i].'<br>';
$i++;	//this is an increment. It's the same as saying $i = $i + 1;s
}
echo "FOR LOOP!<br>";

for ($i=0;$i<count($variable);$i++){
  echo "i is ".$i.' and the value is '.$variable[$i].'<br>';
}

//output the sum of all multiples of 3 and 5 up to 1000
$sum = 0;
for ($i=1;$i<1000;$i++){
//is multiple if $i % 3 == 0
	if ($i%3==0 && $i%5==0){
		$sum += $i;
	}

}
echo 'Sum is '.$sum.'<br>';


$associativearray = array('Teacher'=>'Kris',
	'Student'=>'Madeline',
	'Students'=>array('Michael','Denise','Amy',array(1,2,3))
);
echo $associativearray['Students'][2];
echo '<pre>';
print_r($associativearray);
echo '</pre>';

//we use this for associative arrays
foreach ($associativearray as $key=>$value){
echo $key.' '.$value.'<br>';
}




?>