Page 1 of 1

Help!

Posted: Thu Aug 28, 2003 10:15 pm
by bgood98
Hi, I am new to php scripting so I am just trying things out for fun. Can anyone tell me why this does not work...

Code: Select all

// Create an Arrays
$months = array("January", "February", "March", "April", "May", "June", "July", "August", "September", "October", "November", "December");
$days = array("Sunday", "Monday", "Tuesday", "Thursday", "Friday", "Saturday");

// Get Month Abrevation
$abv = date(M);
if ($abv == "Jan") { $result1 == $monthsї0]; };
if ($abv == "Feb") { $result1 == $monthsї1]; };
if ($abv == "Mar") { $result1 == $monthsї2]; };
if ($abv == "Apr") { $result1 == $monthsї3]; };
if ($abv == "May") { $result1 == $monthsї4]; };
if ($abv == "Jun") { $result1 == $monthsї5]; };
if ($abv == "Jul") { $result1 == $monthsї6]; };
if ($abv == "Aug") { $result1 == $monthsї7]; };
if ($abv == "Sept") { $result1 == $monthsї8]; };
if ($abv == "Oct") { $result1 == $monthsї9]; };
if ($abv == "Nov") { $result1 == $monthsї10]; };
if ($abv == "Dec") { $result1 == $monthsї11]; };
echo $result1;

Posted: Thu Aug 28, 2003 10:33 pm
by volka
first you have to quote string literals

Code: Select all

$abv = date('M');
second
$result1 == $months[0];
compares $result1 and $months[0] for equality but you want to assign the value

Code: Select all

$result1 = $months[0];
and last but not least just try

Code: Select all

echo date('F l');
;)

see also:
http://php.net/date
http://php.net//language.types.string
http://php.net/language.operators.comparison
http://php.net/language.operators.assignment

Posted: Thu Aug 28, 2003 10:49 pm
by bgood98
Thank you

I am just learning to code, so I am trying out arrays and such and this seemed a simple way to do it.