Home Accessibility Courses Diary The Mouth Forum Resources Site Map About Us Contact
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
C205 - C and C based languages - Arrays
H106 - PHP - Arrays
J705 - Java - Arrays
T208 - Tcl/Tk - Arrays

Back to
Regular expression for 6 digits OR 25 digits
Previous and next
or
Horse's mouth home
Forward to
PHP training courses every month
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
2259 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, 35, 36, 37, 38, 39, 40, 41, 42, 43, 44, 45, 46 at 50 posts per page


This 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).

© WELL HOUSE CONSULTANTS LTD., 2009: Well House Manor • 48 Spa Road • Melksham, Wiltshire • United Kingdom • SN12 7NY
PH: 01144 1225 708225 • FAX: 01144 1225 707126 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho