<?php 

		$string = "Vendo moto usada, entre em contato 1188889999, moto@usada.com, www.moto.com, http://m...content-available-to-author-only...o.com";

		// captura todos os emails da string
		preg_match_all('/[A-z0-9]+@[A-z0-9\.]+/', $string, $match_email);

		// captura todos os sites da string
		preg_match_all('/(www\.|http:\/\/|https:\/\/)+[A-z0-9\.]+/', $string, $match_site);

		// captura todos os telefones da string
		preg_match_all('/[0-9\-\(\)]+/', $string, $match_phone);

		

		// altera os emails encontrados 
		$emails = $match_email[0];
		foreach($emails as $email){
			
			$newEmail = alterar_email($email);
			$string = str_replace($email,$newEmail,$string);
			
		}

		
		// altera os telefones encontrados 
		$phones = $match_phone[0];
		foreach($phones as $phone){
			
			$newPhone = alterar_telefone($phone);
			$string = str_replace($phone,$newPhone,$string);
			
		}
		
		
		// altera os telefones encontrados 
		$sites = $match_site[0];
		$inicioSites = $match_site[1];
		
		for($s = 0; $s < count($sites); $s++){
			$sewSite = alterar_site($sites[$s], $inicioSites[$s]);
			$string = str_replace($sites[$s],$sewSite,$string);
		}

		echo $string;

		// função que altera o email
		function alterar_email($email){
			
			$newStringEmail = "";
			$partesEmail = explode("@", $email); // separar em duas partes
			 
			/*
				primeira parte do email
				"moto"
			
			*/
			
			for($y = 0; $y < strlen($partesEmail[0]); $y++){
				if($y == 0) {
					$newStringEmail .= $partesEmail[0][0];
				} else {
					$newStringEmail .= "*";
				}
			}
			
			$newStringEmail .= "@"; // adicionando o "@" que foi perdido
			
			/*
			
				segunda parte do email
				"usada.com"
			
			*/
			
			$parts2 = explode(".", $partesEmail[1]);
			for($z = 0; $z < strlen($parts2[0]); $z++){
				$newStringEmail .= "*";
			}
			
			for($x = 1; $x < count($parts2); $x++){
				$newStringEmail .= ".".$parts2[$x];
			}
			return $newStringEmail;
		}


		function alterar_site($site, $inicio){
			
			$newStringSite = $inicio;
			$parteInicialSite = explode($inicio,$site);
			$partesSite = explode(".",$parteInicialSite[1]);
			for($x = 0; $x < strlen($partesSite[0]); $x++){
				$newStringSite .= "*";
			}
			for($y = 1; $y < count($partesSite); $y++){
				$newStringSite .= ".".$partesSite[$y];
			}
			return $newStringSite;
		}

		function alterar_telefone($phone){
			
			$num = 0;
			$newStringPhone = "";
			$positions = array(1,2,7,8); // posições que não serão substituidos
			
			for($x = 0; $x < strlen($phone); $x++){
				if(is_numeric($phone[$x])){
					$num++;
					if(in_array($num,$positions)){
						$newStringPhone .= $phone[$x];
						continue;
					}
					$newStringPhone .= "*";
					continue;
				} 
				$newStringPhone .= $phone[$x];
			}
			return $newStringPhone;
		}