Permalink
Fetching contributors…
Cannot retrieve contributors at this time
13 lines (12 sloc) 333 Bytes
* return position of the target string in the string.
* return -1 if target string does not exist.
function find( str, tar )
l_str = math_strlen( str )
l_tar = math_strlen( tar )
i = 1
while( i <= l_str - l_tar + 1 )
tmp = substr( str, i, l_tar )
if( tmp = tar ) ; return i ; endif
i = i + 1
endwhile
return -1