TOP TECH
  Learn How to.....
Welcome IT Related Articles Member Area  |  Sign In  |  Sign Up
.: Home :.
General
HTML
CSS
PHP
PHP-MySQL
FrontPage
Photoshop
CorelDRAW
PageMaker
MS Office
VisualBasic
All
.

.: Home :.

Home >> PHP - MySQL
Programming with PHP 2.2 [Page 3]
Article by: Shelton Manage
Wednesday, 03rd June, 2009


To create an access arrays

This first array will use numbers for the keys, from 1 to 12. Since I specified the first key, the following values will be indexed incrementally. For days and years arrray s to used the range function.

// Make the months array.
$months = array ( 1 => 'January', 'February', 'March', 'April', 'May', 'June', 'July', 'August', 'September', 'October', 'November', 'December');

// Make the day and years array.
$days = range (1, 31);
$years = range (2003, 2010);

calendar.phps | calendar.php

To determine the number of elements in an array, use the count() or sizeof() functions. (the two are synonymouse)
$num = count($array);

The range function can create also $alphabet = range (a, z);

for each constuct will not affect the array itself.
An array's key can be multiple-worded strings, such as first name or phone number in wich case you must surround the key in quotion marks when reffering it.

The is_array() function comfirms that a variable is of the array type.

You don't6 have to use the names $key and $valuue in your foreach loop. but those are logical choices.(somem programmers abbreviate them to $ and $v).



Page: First - 1 2 3 4 5 6 - Last

 



Comments


© 2009 Top Sri Lanka Top Tech.
Articles Manager β - Script by: DynamicCodes.com