Home Accessibility Courses Twitter The Mouth Facebook Resources Site Map About Us Contact
 
Python and Tcl - public course schedule [here]
Private courses on your site - see [here]
Please ask about maintenance training for Perl, PHP, Lua, etc
 
Arrays in PHP - contain different and even mixed data types

PHP's arrays can be keyed by both value and by string... and on this week's PHP course we've covered both. An indexed array (not really an array - rather akin to a list in Perl or Python) starts at index element number 0 and works up from there. Each array member may contain a different type of data, and the members may be of different sizes. And they can be set up initially with an array function call, or by return from any number of functions.

A mixture of ints and floats:
  $speeds = array(0,1,5.5,11,19,28,38,49,61,74,88,102,117);

Strings of different length:
  $windy = array("Calm","Light Air","Light Breeze","Gentle Breeze" ...

The resultant parts from an explode function:
  $current = explode("\t",$station);

The rows of data returned by a web service:
  $stations = file("http://www.wellho.net/data/railstats.xyz");

Once an array has been set up, you can even add other values onto the end of it ...

Source code example, together with a demonstration of looping through an array to find a threshhold value (conversion of wind speed to beaufort scale) from the course - [here].

(written 2013-04-24, updated 2013-05-04)

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


Back to
The woman, the television, the bullock and Darlington
Previous and next
or
Horse's mouth home
Forward to
Even early on, separate out your program from your HTML!
Some other Articles
Setting up strings in PHP
Passing variable between PHP pages - hidden fields, cookies and sessions
Even early on, separate out your program from your HTML!
Arrays in PHP - contain different and even mixed data types
The woman, the television, the bullock and Darlington
MVC and Frameworks - a lesson from first principles in PHP
Handling requests to a forum - the background process
Apache httpd - a robust, open source web server
Backups by crossover between network centres - setting up automatic scp transfers
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., 2019: 404 The Spa • Melksham, Wiltshire • United Kingdom • SN12 6QL
PH: 01225 708225 • EMAIL: info@wellho.net • WEB: http://www.wellho.net • SKYPE: wellho

PAGE: http://www.wellho.net/mouth/4068_Arr ... types.html • PAGE BUILT: Sat May 27 16:49:10 2017 • BUILD SYSTEM: WomanWithCat