Welcome to PHPMule.com
A blog site which I am posting to during my learning of the popular programming language PHP. Feel free to leave comments!
-
PHP - Using Loops With Arrays
There’s an even better way of displaying a numerical array’s contents by using a loop because the array is basically indexed by numbers.
We can use a ‘for’ loop to do this:
for ($counter = 0; $counter<10; $counter++) {
echo $celebrity_array[$counter] . ” “;
}
There’s another loop which you could use which was designed for arrays in the first place and that’s the ‘foreach’ loop:
foreach ($celebrity_array as $action_heroes) {
echo $action_heroes. ” “;
}
Here is a while loop that uses the each construct.
while ($variable = each($numbers)) {
echo $element['key'];
echo ” - “;
echo $element['value'];
echo “<br />”;
}
(Post created on Monday, April 13th 09 at 14:15)
-
Calendar
| M | T | W | T | F | S | S |
|---|---|---|---|---|---|---|
| « Jun | ||||||
| 1 | 2 | 3 | 4 | 5 | ||
| 6 | 7 | 8 | 9 | 10 | 11 | 12 |
| 13 | 14 | 15 | 16 | 17 | 18 | 19 |
| 20 | 21 | 22 | 23 | 24 | 25 | 26 |
| 27 | 28 | 29 | 30 | |||
Archives
Recent Articles
- PHP - Rounding Off Numbers
- PHP - Single vs Double Quotation Marks
- PHP - Loading Files Into Your PHP Script By Using require() and include()
- PHP - Replacing Strings With Other Strings
- PHP - Finding Strings Within Strings
- PHP - Using strlen() To Test String Length
- PHP - Using The explode() Function
- PHP - Changing The String Case
- PHP - The nl2br() Function
- PHP - Trimming Strings
Links
Categories
- PHP (22)
- Uncategorized (1)


