PHP Tizag Tutorial-41 PDF
PHP Tizag Tutorial-41 PDF
In an associative array a key is associated with a value. If you wanted to store the salaries of your
employees in an array, a numerically indexed array would not be the best choice. Instead, we could use the
employees names as the keys in our associative array, and the value would be their respective salary.
PHP Code:
$salaries["Bob"] = 2000;
$salaries["Sally"] = 4000;
$salaries["Charlie"] = 600;
$salaries["Clare"] = 0;
Display:
Bob is being paid - $2000
Sally is being paid - $4000
Charlie is being paid - $600
Clare is being paid - $0
Once again, the usefulness of arrays will become more apparent once you have knowledge of for and
while loops.