note 52312 added to function.fnmatch

From: Date: Wed, 27 Apr 2005 16:04:55 +0000
Subject: note 52312 added to function.fnmatch
Groups: php.notes 
Request: Send a blank email to php-notes+get-88642@lists.php.net to get a copy of this message
/******************************************************************\ * sql_match Written by Joshua C. Butcher * * Works like the like() functionality in SQL * * %zealbot% matches zealbot 1234zealbot and zealbodt1234 * * zealbot% matches zealbot1234 * * %zealbot matches 1234zealbot * * zealbot matches only zealbot * /******************************************************************/ function sql_match($pattern,$data) { $lp=strlen($pattern); $ld=strlen($data); $ip=0; $id=0; for ($ip=0; $ip<$lp; $ip++) { if ($pattern[$ip]=='%') { $ip++; if ($ip >= $lp) { return true; } for (;;) { if ($pattern[$ip] == $data[$id]) { break; } else { $id++; if ($id > $ld) { return true; } } } } if ($pattern[$ip] <> $data[$id]) { return false; } $id++; } if ($ld <> $lp) { return false; } return true; } ---- Manual Page -- http://www.php.net/manual/en/function.fnmatch.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+52312 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+52312&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+52312&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+52312&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+52312&report=yes&reason=useless Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+52312&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+52312&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#88642) next »