Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
For 2021 - online Python 3 training - see ((here)).

Our plans were to retire in summer 2020 and see the world, but Coronavirus has lead us into a lot of lockdown programming in Python 3 and PHP 7.
We can now offer tailored online training - small groups, real tutors - works really well for groups of 4 to 14 delegates. Anywhere in the world; course language English.

Please ask about private 'maintenance' training for Python 2, Tcl, Perl, PHP, Lua, etc.
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, updated 2008-04-19)

 
Associated topics are indexed as below, or enter http://melksh.am/nnnn for individual articles
T208 - Tcl/Tk - Arrays and dicts
  [122] Passing arrays to procs in Tcl - (2004-11-18)
  [779] The fragility of pancakes - and better structures - (2006-06-26)
  [1282] Stringing together Tcl scripts - (2007-07-29)
  [1283] Generating traffic for network testing - (2007-07-29)
  [1405] Sorting in Tcl - lists and arrays - (2007-10-24)
  [1427] Arrays in Tcl - a demonstration - (2007-11-10)
  [2466] Tcl - passing arrays and strings in and back out of procs - (2009-10-22)
  [3192] Tcl - Some example of HOW TO in handling data files and formats - (2011-03-04)
  [3415] User defined sorting and other uses of callbacks in Tcl and Tk - (2011-09-02)
  [3582] Tcl collections - lists, dicts and array - (2012-01-16)
  [3614] Tcl - dicts - a tutorial and examples - (2012-02-14)
  [3638] Sorting dicts and arrays in Tcl - (2012-03-04)

J705 - Java - Arrays
  [1497] Training Season Starts again! - (2008-01-07)
  [1498] Java is a dynamic language .... (and comparison) - (2008-01-08)
  [2648] Java arrays - are they true arrays or not? - (2010-02-23)
  [3038] Setting up individual variables, and arrays, in Java - some commented examples - (2010-11-09)
  [3039] Fresh Paint - Java Arrays - (2010-11-09)
  [3118] Arrays of arrays - or 2D arrays. How to program tables. - (2011-01-02)
  [4347] Arrays in Java - an introduction for newcomers - (2014-12-10)
  [4413] Binomial Coefficient (Pascal Triangle) objects in Java - (2015-02-03)
  [4428] Using the lead - passing arrays and other collections in Java - (2015-02-16)

H106 - PHP - Arrays
  [409] Functions and commands with dangerous names - (2005-08-11)
  [603] PHP - setting sort order with an associative array - (2006-02-13)
  [773] Breaking bread - (2006-06-22)
  [832] Displaying data at 5 items per line on a web page - (2006-08-14)
  [1116] PHP adding arrays / summing arrays - (2007-03-23)
  [1199] Testing for one of a list of values. - (2007-05-22)
  [1451] More PHP sample and demonstration programs - (2007-12-01)
  [2215] If nothing, make it nothing. - (2009-06-02)
  [2274] PHP preg functions - examples and comparision - (2009-07-08)
  [2915] Looking up a value by key - associative arrays / Hashes / Dictionaries - (2010-08-11)
  [2920] Sorting - naturally, or into a different order - (2010-08-14)
  [3004] Increment operators for counting - Perl, PHP, C and others - (2010-10-18)
  [3379] Sorting data the way YOU want it sorted - (2011-08-05)
  [3534] Learning to program in PHP - Regular Expression and Associative Array examples - (2011-12-01)
  [4068] Arrays in PHP - contain different and even mixed data types - (2013-04-24)
  [4072] Splitting the difference with PHP - (2013-04-27)
  [4244] Disambiguation - PHP List - (2014-03-07)

C205 - C and C based languages - Arrays
  [2002] New C Examples - pointers, realloc, structs and more - (2009-01-20)
  [2840] Just pass a pointer - do not duplicate the data - (2010-06-30)
  [3121] New year, new C Course - (2011-01-05)
  [3144] Setting up arrays in C - fixed size at compile time, or dynamic - (2011-01-24)
  [3245] Collections in C and C++ - arrays, vectors and heap memory blocks - (2011-04-12)
  [4338] Passing arrays into functions in C - (2014-12-02)
  [4566] C - why is slow to write and debug) but fast to run? - (2015-11-01)


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
4759 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, 47, 48, 49, 50, 51, 52, 53, 54, 55, 56, 57, 58, 59, 60, 61, 62, 63, 64, 65, 66, 67, 68, 69, 70, 71, 72, 73, 74, 75, 76, 77, 78, 79, 80, 81, 82, 83, 84, 85, 86, 87, 88, 89, 90, 91, 92, 93, 94, 95, 96 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).

You can Add a comment or ranking to this page

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

PAGE: http://www.wellho.net/mouth/1614_Whe ... array.html • PAGE BUILT: Sun Oct 11 16:07:41 2020 • BUILD SYSTEM: JelliaJamb