PHP: Associative array

This entry is part 23 of 54 in the series PHP Tutorial

Beside the indexed array, PHP also supports associative array.

Here, in the example below, we show how an associative array is formed.

<?php

$car = array('weight' => '1000kg', 'year' => 2004, 'price' => 7000);

echo "Weight of car: " . $car['weight'];
echo "\n";
echo "Year of car: " . $car['year'];
echo "\n";
echo "Price of car: " . $car['price'];
echo "\n";

?>

Series Navigation<< PHP: Sorting an array
PHP: Conditional statements >>

Leave a comment

Leave a Reply