Log in

View Full Version : help with if else



mulaus
09-11-2009, 02:15 PM
month value is January

and monthYear value in db is January 09


how do i make the if else to ignore the 09 to make the condition above to be true




if($month== $monthYear) {
echo "True";
} else {
echo "False";
}
}


is this possible?

forum_amnesiac
09-11-2009, 03:23 PM
Try this


$monthlength=strlen(trim($month));

if(strtoupper(trim($month))== substr(strtoupper(trim($monthYear)),0,$monthlength)) {
echo "True";
} else {
echo "False";
}
}

I have used strtoupper() to ensure that 'January' would match with 'JANUARY'

mulaus
09-11-2009, 04:46 PM
thanks...awesome...you rock..it works