sscanf is my white whale

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
SpiderMonkey
Forum Commoner
Posts: 85
Joined: Fri May 05, 2006 4:48 am

sscanf is my white whale

Post by SpiderMonkey »

Hi, I'd appreciate it if someone could look at this bit of code for me:

Code: Select all

$mi=1;
  foreach ($months as $month) {
      $searchstring="%[^1-9]%d[tsrn][htd] $month %d%[^[]]";
      if (sscanf($lsearch,$searchstring, $a, $b, $d, $e)>2) {
        if ($d<2000) $d+=2000;
        $datesearch="$b/$mi/$d";
        $locsearch="$a$e";
     }
     $mi++;
  }
Its intended to parse dates and remove them from the input string ($lsearch)
$months contains the short names of the months in order (jan,feb,mar etc)

I'm wanting it to pick up things like '5th may' but it isn't doing so.
Post Reply