# Posted By

jamesming on 07/18/08

# Statistics

Viewed 510 times
Favorited by 1 user(s)

# extract string between

/ Published in: PHP
`function TextBetweenArray(\$s1,\$s2,\$s){			\$myarray=array();			\$s1=strtolower(\$s1);			\$s2=strtolower(\$s2);			\$L1=strlen(\$s1);			\$L2=strlen(\$s2);			\$scheck=strtolower(\$s);			do{				\$pos1 = strpos(\$scheck,\$s1);				if(\$pos1!==false){					\$pos2 = strpos(substr(\$scheck,\$pos1+\$L1),\$s2);					if(\$pos2!==false){						\$myarray[]=substr(\$s,\$pos1+\$L1,\$pos2);						\$s=substr(\$s,\$pos1+\$L1+\$pos2+\$L2);						\$scheck=strtolower(\$s);					}				}			} while ((\$pos1!==false)and(\$pos2!==false));			return \$myarray;	} function TextBetween(\$s1,\$s2,\$s){			\$s1 = strtolower(\$s1);			\$s2 = strtolower(\$s2);			\$L1 = strlen(\$s1);			\$scheck = strtolower(\$s);			if(\$L1>0){\$pos1 = strpos(\$scheck,\$s1);} else {\$pos1=0;}			if(\$pos1 !== false){				if(\$s2 == '') return substr(\$s,\$pos1+\$L1);				\$pos2 = strpos(substr(\$scheck,\$pos1+\$L1),\$s2);				if(\$pos2!==false) return substr(\$s,\$pos1+\$L1,\$pos2);			}			return '';	}`