On 5/22/07, Greg Donald <[EMAIL PROTECTED]> wrote:

On 5/22/07, Daniel Brown <[EMAIL PROTECTED]> wrote:
> <?
> function num2day($num) {
>     if($num == "1") {
>         $day = "Sunday";
>     } elseif($num == "2") {
>         $day = "Monday";
>     } elseif($num == "3") {
>         $day = "Tuesday";
>     } elseif($num == "4") {
>         $day = "Wednesday";
>     } elseif($num == "5") {
>         $day = "Thursday";
>     } elseif($num == "6") {
>         $day = "Friday";
>     } elseif($num == "7") {
>         $day = "Saturday";
>     }
>     return $day;
> }
> ?>

PHP does automatic type conversions, even if $num is passed in as a
string all those quotes around the integers are not necessary.  There
is no variable interpolation required in the day names so all those
double quotes should be single quotes.  A function call seems rather
heavy when a global array can be indexed more easily.  Even a switch
statement would be an improvement.


--
Greg Donald
http://destiney.com/

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php


   You may have noticed my disclaimer at the head of the message.  It was
there for just that reason....

--
Daniel P. Brown
[office] (570-) 587-7080 Ext. 272
[mobile] (570-) 766-8107

Reply via email to