Ok guys im new to php taught myself years back, and now decided to build a script that i needed so really rusty and just learning and remembering as i go along.
Ok basically I'm having trouble seeing if a varible = value in a if statement. See code below.
Basically im using the explode function to parse => $row['timedate'] witch always looks something like this =>
"14:02:30 Aug 20, 2016" and im putting in the values into the $date_array varible.
Then im adding the value of $date_array[2] to $str_month which now holds the month. Which in this case would be "Aug"
it then goes to the if statements and should assign the the text month value to its numeric value, but its just not doing it. What im i doing wrong? I just cant seem to get this to work! It should be fairly simple but im lost.
Looking forward to hearing back.
Thanks.
$date_array = explode(" ",$row['timedate']);
$str_month = $date_array[2];
if ($str_month == 'Jan') {
$str_month = '1';
}
if ($str_month == 'Feb') {
$str_month = '2';
}
if ($str_month == 'Mar') {
$str_month = '3';
}
if ($str_month == 'Apr') {
$str_month = '4';
}
if ($str_month == 'May') {
$str_month = '5';
}
if ($str_month == 'June') {
$str_month = '6';
}
if ($str_month == 'July') {
$str_month = '7';
}
if ($str_month == 'Sept') {
$str_month = '9';
echo "its sept";
}
if ($str_month == 'Oct') {
$str_month = '10';
}
if ($str_month == 'Nov') {
$str_month = '11';
}
if ($str_month == 'Dec') {
$str_month = '12';
}