Learn web design and programming with our free video and text tutorials.
Web Designer? Design and market your own professional website with easy-to-use tools.
Browse our HTML, XHTML and CSS tutorials to learn how to create your website at LearnWebsiteDesign.com or download one of our free website templates.
Providing high quality free software to download
PHP numeric arrays allow you to access the values in the array in numeric order through the use of numeric ID keys.
Numeric keys in PHP arrays always begin with a zero (0).
<?php
$days = array('Monday', 'Tuesday', 'Wednsday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
$whatDayIsIt = $days[0];
echo "The day is $whatDayIsIt.";
?>
The code above outputs:
The day is Monday.
You can also change a value at a given index.
The first value in the code example below is changed.
<?php
$days = array('some day', 'Tuesday', 'Wednsday', 'Thursday', 'Friday', 'Saturday', 'Sunday');
$whatDayIsIt = $days[0];
echo "The day is $whatDayIsIt.";
?>
The code above outputs:
The day is some day.
You can also add a value.
<?php
$days = array('Monday', 'Tuesday', 'Wednsday', 'Thursday', 'Friday', 'Saturday', 'Sunday', 'some day');
$whatDayIsIt = $days[7];
echo "The day is $whatDayIsIt.";
?>
The code above outputs:
The day is some day.