Results 1 to 3 of 3

Thread: help with if else

  1. #1
    Join Date
    Sep 2009
    Posts
    48
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default help with if else

    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

    PHP Code:

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

    is this possible?

  2. #2
    Join Date
    Apr 2009
    Location
    Cognac, France
    Posts
    400
    Thanks
    2
    Thanked 57 Times in 57 Posts

    Default

    Try this

    PHP Code:
    $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'

  3. The Following User Says Thank You to forum_amnesiac For This Useful Post:

    mulaus (09-11-2009)

  4. #3
    Join Date
    Sep 2009
    Posts
    48
    Thanks
    6
    Thanked 0 Times in 0 Posts

    Default

    thanks...awesome...you rock..it works

Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •