note 60455 added to function.strcasecmp

From: Date: Sat, 07 Jan 2006 18:13:21 +0000
Subject: note 60455 added to function.strcasecmp
Groups: php.notes 
Request: Send a blank email to php-notes+get-101361@lists.php.net to get a copy of this message
I don't know if something like that already exsists, but I just wrote a function to find out if a certain string is contained into another longer. For example, you can use this function if you to make a directory listing avoiding all the subdirectories. function contains($str, $pattern) { $len = strlen( $str ); $len_pat = strlen( $pattern ); for( $i = 0; $i < $len; $i ++ ) { $check = substr( $str, $i, $len_pat ); if ( strcasecmp( $check, $pattern ) == 0 ) { return true; } } return false; } $str is the string you're watching in $pattern is the string you want to verify the presence ---- Manual Page -- http://www.php.net/manual/en/function.strcasecmp.php Edit -- http://master.php.net/manage/user-notes.php?action=edit+60455 Delete: added to the manual -- http://master.php.net/manage/user-notes.php?action=delete+60455&report=yes&reason=added+to+the+manual Delete: bad code -- http://master.php.net/manage/user-notes.php?action=delete+60455&report=yes&reason=bad+code Delete: spam -- http://master.php.net/manage/user-notes.php?action=delete+60455&report=yes&reason=spam Delete: useless -- http://master.php.net/manage/user-notes.php?action=delete+60455&report=yes&reason=useless Delete: non-english -- http://master.php.net/manage/user-notes.php?action=delete+60455&report=yes&reason=non-english Delete: already in docs -- http://master.php.net/manage/user-notes.php?action=delete+60455&report=yes&reason=already+in+docs Delete: other reasons -- http://master.php.net/manage/user-notes.php?action=delete+60455&report=yes Reject -- http://master.php.net/manage/user-notes.php?action=reject+60455&report=yes Search -- http://master.php.net/manage/user-notes.php

« previous php.notes (#101361) next »