RE: [PHP-GENERAL] Arrays
| From: | Roy Nasser | Date: | Mon, 12 Jun 2000 05:11:28 +0000 |
| Subject: | RE: [PHP-GENERAL] Arrays | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-1591@lists.php.net to get a copy of this message | ||
Hi Dhaval,
I am no php genious, but arrays can be very useful when you have a large
amount of possibilities based on a value or on a string (hashes)...
for example...
If you want to output the name of a day of the week in enmglish you can have
the following
$day = 1; //(Monday)
$name_day[0] = "Sunday";
$name_day[1] = "Monday";
$name_day[2] = "Tuesday";
$name_day[3] = "Wednesday";
$name_day[4] = "Thursday";
$name_day[5] = "Firday";
$name_day[6] = "Saturday";
print $name_day[$day];
(This would be the same as writing "print $name_day[1]")... And if you see
above $name_day[1] is "Monday"...
Hashes can be used for other things and are also very useful...
You could have the following for example:
to display the word "car" in different languages...
$car["english"] = "car";
$car["portuguese"] = "carro";
$car["french"] = "voiture";
print "English: ".$car["english"]."\n";
print "Português: ".$car["portuguese"]."\n";
print "Français: ".$car["french"]."\n";
I hope this helps!
Cheers from BRasil,
Roy
> -----Original Message-----
> From: dhaval desai [mailto:dhaval_adams@hotmail.com]
> Sent: Monday, June 12, 2000 2:02 AM
> To: php-general@lists.php.net
> Subject: [PHP-GENERAL] Arrays
>
>
> Hi!
>
> I am new to Php3...
> I am using mysql as the database.
> CAn anyone give me an intro to using arrays...and why exactly do we use
> arrays.
>
>
> Thanx a lot guys
> Dhaval Desai
>
>
> ________________________________________________________________________
> Get Your Private, Free E-mail from MSN Hotmail at ÐêrÐ]ðBM
> 4Øþ1http://www.hotmail.com
>
>
> --
> PHP General Mailing List (http://www.php.net/)
> To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net
> For additional commands, e-mail: php-general-help@lists.php.net
> To contact the list administrators, e-mail: php-list-admin@lists.php.net
>