StupidRalph
Solid State Member
- Messages
- 14
I am having problems with the code below complaining of the undefined index.
If I were to use:
It will not throwout any errors.
However if I were to use:
It complains of having an undefined index.
I can echo out the variable $currentMonth have it return 08 since today is in August the eigth month of the year. So I don't see the difference when $currentMonth= 08 and when I manually type in 08 in the array index.
PHP:
<?php
//Months in the year
$month[0] = 'January';
$month[01] = 'February';
$month[02] = 'March';
$month[03] = 'April';
$month[04] = 'May';
$month[05] = 'June';
$month[06] = 'July';
$month[07] = 'August';
$month[08] = 'September';
$month[09] = 'October';
$month[10] = 'November';
$month[11] = 'December';
//Current month
$currentMonth = date('m');
echo $month[$currentMonth];
?>
If I were to use:
PHP:
echo $month[08];
It will not throwout any errors.
However if I were to use:
PHP:
echo $month[$currentMonth];
It complains of having an undefined index.
I can echo out the variable $currentMonth have it return 08 since today is in August the eigth month of the year. So I don't see the difference when $currentMonth= 08 and when I manually type in 08 in the array index.