| |||||||||||
| |||||||||||
Don't repeat code - use loops or functions
I've just answered a question about completing a whole series of radio boxes in a form, where the questioner provided sample code that had the same line, slightly modified, appearing time and time again. But if you find yourself repeating something, there must be an easier way and that way will be either a function or a loop ... the initial coding may be more complex, but when you come to expand your list of options from 5 to 15 to 50, you'll be thanking me for the advise!
I've coded an answer to the original question, written in PHP, and you can try the example here. I've included a call to the highlight_file function so that you can see the code ... and I've even commented my PHP! (written 2005-08-21 07:29:30) Associated topics are indexed under H104 - PHP - Control StatementsH105 - PHP - Functions H108 - Objects in PHP
Some other Articles
Caching an XML feedHow not to run a forum A Victorian Lady PHP Magic Quotes Don't repeat code - use loops or functions Towards Tebay Most popular courses Difference between import and from in Python Telephone Preference Service - we're registered Mixing up swallows and martins 1638 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 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 | |||||||||||