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 - Accessing And Replacing Array Contents
To access the contents of an array, you use it’s variable name along with its key (index) such as:
$celebrity_array[0]
so you can use it’s contents.
You can use array variables as you would with normal variables and you could easily change it’s contents by using the ‘=’ operator like the following example:
$celebrity_array[0] = ‘Daniel Craig’ ;
This line will change the contents of [0] to Daniel Craig. It was Bruce Willis by the way but now he’s gone…
(Post created on Friday, April 10th 09 at 23:35)
-
PHP - Using Arrays (Numerically Indexed)
An array is a variable that can store a set of values.
Numerically Indexed Arrays
If you wanted to store a set of values in one variable we could do that as follows:
$celebrity_array[0] = “Bruce Willis”;
$celebrity_array[1] = “Arnold Swarzennegar”;
$celebrity_array[2] = “Matt Damon”;
$celebrity_array[3] = “Liam Neeson”;
If we then wanted to reference to this we could use these lines:
echo “A well known action hero is ” . $celebrity_array[0] . ” and ” . $celebrity_array[3] . ” is pretty good as well! “;
You will also notice that the counter starts at ‘[0]‘ and it’s something you would have to get used to if you haven’t seen an array before.
Arrays obviously save time and it will make your code look a little tidier. I will go more into arrays in the next blog post as I’m still learning
(Post created on Thursday, April 9th 09 at 15:35)
-
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)


