function findtxt($start,$end,$str,&$var) { if(stristr($str,$start) && stristr($str,$end)) { $txt_pos_s = strpos($str,$start) + strlen($start); $txt_pos_e = strpos($str,$end,$txt_pos_s); $txt_length = $txt_pos_e - $txt_pos_s; $txt = substr($str,$txt_pos_s,$txt_length); $var = $txt; return TRUE; } else { return FALSE; } } //Call the function $str="Address 1: Cairo 14 Street </br> Address 2: bla bla bla "; findtxt('Address 1:','Address 2:',$str,$s1); // then you can remove the html tags from the result string which is $s1 $s1=strip_tags($s1);