Tecnologia

Verificar se string começa ou termina com determinado texto

 
function comecaCom($string, $search_string) {
	// search backwards starting from string length characters from the end
	return $search_string === "" || strrpos($string, $search_string, -strlen($string)) !== false; 
} 

function terminaCom($string, $search_string) {
	// search forward starting from end minus search_string length characters
	return $search_string === "" || (($temp = strlen($string) - strlen($search_string)) >= 0 && strpos($string, $search_string, $temp) !== false);
}
2020 © B85 Tecnologia
eu@andersonbravo.com.br