PHP: Indexed Arrays I

Derek Bridge

Department of Computer Science,
University College Cork

PHP: Indexed Arrays I


Life without arrays

Life with arrays

Indexed arrays

Indexed arrays

Accessing the elements in an indexed array

Non-consecutive indexes

Doing things to each value in an indexed array

Class exercise: what is the output of the following?

echo "<ul>";
foreach ($toppings as $topping) 
    echo "<li>{$topping}</li>";
echo "</ul>";

Class exercise