| |||||||||||
| |||||||||||
When an array is not an array
An array, I was taught, is a sequential series of memory locations in which values of some type are stored. In an array, each of the memory locations is the same size (number of bytes). And so, as I was taught, arrays can be used very efficiently using pointer arithmetic, BUT they need to:
a) Be defined in advance b) Have each element given enough memory to allow for the biggest content and c) They cannot be lengthened later d) Taking an element out in the middle calls for a lot of shuffling up. Arrays in PHP and in Tcl are NOT arrays! The word "array" is used more loosely to define a collection object which is (in computer science terms) either a link list or a hash. And that means ... i) You can define PHP or Tcl arrays as you need them ii) Elements can have different sizes iii) Arrays in Tcl of PHP can be expanded as need be iv) Elements can be deleted easily from the middle v) Elements can be named (PHP's "associative arrays, all Tcl arrays) rather than numbered You gain all that flexibility ... what do you loose? For a few applications - the intense dataprocessing / calculation ones - your application may slow down a bit. Since PHP is a web server language where you aren't typically doing such calculations, that turns out to be no loss at all! (written 2008-04-17 06:40:22) Associated topics are indexed under H106 - PHP - ArraysT208 - Tcl/Tk - Arrays C205 - C and C based languages - Arrays J705 - Java - Arrays
Some other Articles
A small picture does not always cut it!Steam Engines at Bressingham Not daring to be an anorak PHP training courses every month When an array is not an array Regular expression for 6 digits OR 25 digits Comfy Chair - Floating Harbour, Bristol Gauging point at entrance to Bristols Floating Harbour PHP course dot co, dot uk Chew Valley Lakes 1696 posts, page by page
Link to page ... 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, 31, 32, 33, 34 at 50 posts per pageThis is a page archived from The Horse's Mouth at http://www.wellho.net/horse/ - the diary and writings of Graham Ellis. Every attempt was made to provide current information at the time the page was written, but things do move forward in our business - new software releases, price changes, new techniques. Please check back via our main site for current courses, prices, versions, etc - any mention of a price in "The Horse's Mouth" cannot be taken as an offer to supply at that price. Link to Ezine home page (for reading). Link to Blogging home page (to add comments). |
| ||||||||||
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho | |||||||||||