Want to chit chat about anything, do it here ... posting here won't increase your post count (or shouldn't!). Please do not post any "phpBB" specific topics here unless they do not fit into the category above. Do not post bug reports, feature or support requests!
Forum rules
Please do not post any "phpBB" specific topics here unless they do not fit into the category above.
Do not post bug reports, feature or support requests! No really... Do not post bug reports, feature or support requests! Doing so will make Bertie a very sad bear indeed. :(
where $my_array is an array. This works in that all instances of $bar are wrapped with <span> in all relevant elements of $my_array, but is this good coding?
First, it has to be a case-preserved replace, so that's why there's a back reference.
Second, my real question is whether or not it's right to modify the contents of an array as shown in the example.
As an alternative, one could for loop through the array and address each element individually - $my_array[$i] - to do this in a way that might be more correct and readable. But if in PHP it's considered normal to examine and modify arrays in their entirety without the [ ] syntax, then there's no point in looping through all the elements of the array.
Where you name the array, than the name of the index, or the name of the storeage place. Like a name tag, or a place holder, than assign a value to it.
You should know an ordinary variable is a place to store data. Image it is a box in the computers memory.
An array is just a group of boxes that can be accessed by the same name, however you use a key to say which box to look in. PHP allows string keys, but some languages have much tighter restrictions (i.e. Java permits only numeric keys starting from 0 and size is fixed before starting to fill array) However as PHP is loose typed it doesn't really bother with this
1 2 3
_______ _______ _______
| bob | | sam | | jan |
|_____| |_____| |_____|
You can refer to your set of boxes as a whole using "myArray" and to a specific part of it with "myArray[2]" for example. Arrays can ofcourse contian other arrays or objects. You can also have multi-dimensionall arrays.