#native_company# #native_desc#
#native_cta#

In String

By jayon crow
on March 21, 2007

Version: 4.0

Type: Function

Category: Algorithms

License: Other

Description: This function returns the position of string s1 within string s2. The position is 1 based. If s1 is not in s2, 0 is
returned.

/* Author: J.B.Lamer, Date: 20070321
 * I suggest using strpos and testing with
 *   the false using triple equals instead of this function.
 * If you don't have strpos, than update your php.
 * Using the original intent of this function
 *   if $needle is in $haystack return the pos (starting from 1)
 *   and 0 on fail or can't find
 * If you want to check if they are strings you can before the if statement
 *   or in the if before checking for pos
 */
function InStr($needle, $haystack)
{
	// suppressing errors with @
	if ( false === ($pos = @strpos($haystack,$needle)) )
	{	return 0; }
	return ($pos+1);
}