note 60455 deleted from function.strcasecmp by nlopess

From: Date: Sat, 07 Jan 2006 20:02:27 +0000
Subject: note 60455 deleted from function.strcasecmp by nlopess
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-101363@lists.php.net to get a copy of this message
Note Submitter: nicolo dot borghi at email dot it ---- 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

« previous php.notes (#101363) next »