array
Format A List Of Items In PHP
Fri, 01/08/2010 - 11:52 | by philipnorton42It is usual when writing a list of items to separate each item with a comma, except the last two items, which are separated with the word "and". I recently needed to implement a function that took a string and converted it into a list of this type so I thought I would expand on it and post it here.
Print Array Without Trailing Commas In PHP
Fri, 04/24/2009 - 09:10 | by philipnorton42I have previously talked about Removing commas from the end of strings, but it is also possible to use the implode() function to do the same sort of thing.
implode() takes two parameters, the separator and the array, and returns a string with each array item separated with the separator. The following example shows how this function works.
PHP Array Of Australian States
Thu, 04/23/2009 - 12:44 | by philipnorton42$australian_states = array(
"NSW"=>"New South Wales",
"VIC"=>"Victoria",
"QLD"=>"Queensland",
"TAS"=>"Tasmania",
"SA"=>"South Australia",
"WA"=>"Western Australia",
"NT"=>"Northern Territory",
"ACT"=>"Australian Capital Terrirory"); PHP Array Of Canadian States
Thu, 04/23/2009 - 12:42 | by philipnorton42Use the following array to print out a list of Canadian states, also know as provinces.
PHP Array Of USA States
Thu, 04/23/2009 - 12:32 | by philipnorton42Use the following array if you want to print out a list of USA states either as a list, or as a select box.
PHP Script To Select A Person To Make The Tea
Mon, 04/06/2009 - 10:05 | by philipnorton42In any office there can be arguments about who will make the next round of tea. The following script will allow you to randomly pick a person who is going to make the tea. Rather than have a script that did this once and threw away the information I thought it would be a good idea to use cookies to save the form data for the next time you want to pick a person to make the tea. This is a good exercise if you are trying to understand how cookies work.
First, we will need to variables, the first is an array of people and the second is the number of people in the office.