note 82229 modified in function.strpos by danbrown

From: Date: Sun, 17 May 2009 16:30:18 +0000
Subject: note 82229 modified in function.strpos by danbrown
References: 1  Groups: php.notes 
Request: Send a blank email to php-notes+get-154836@lists.php.net to get a copy of this message
This might be useful. <?php class String{ //Look for a $needle in $haystack in any position public static function contains(&$haystack, &$needle, &$offset) { $result = strpos($haystack, $needle, $offset); return $result !== FALSE; } //intuitive implementation .. if not found returns -1. public static function strpos(&$haystack, &$needle, &$offset) { $result = strpos($haystack, $needle, $offset); if ($result === FALSE ) { return -1; } return $result; } }//String ?> --was-- This might be useful. class String{ //Look for a $needle in $haystack in any position public static function contains(&$haystack, &$needle, &$offset) { $result = strpos($haystack, $needle, $offset); return $result !== FALSE; } //intuitive implementation .. if not found returns -1. public static function strpos(&$haystack, &$needle, &$offset) { $result = strpos($haystack, $needle, $offset); if ($result === FALSE ) { return -1; } return $result; } }//String http://php.net/manual/en/function.strpos.php

« previous php.notes (#154836) next »