<?php
error_reporting(-1);

$arr = array('84951234567', '+74951234567', '8-495-1-234-567', ' 8 (8122) 56-56-56', '8-911-1234567', '8 (911) 12 345 67', '8-911 12 345 67', '8 (911) - 123 - 45 - 67', '+ 7 999 123 4567', '8 ( 999 ) 1234567', '8 999 123 4567');
$check = '#^(\\-|\\(|\\)| )*(([+](\\-|\\(|\\)| )*7)|8)((\\-|\\(|\\)| )*[0-9]){10}$#';
$zamena = '#((\\-|\\(|\\)| )*([+](\\-|\\(|\\)| )*7))(\\-|\\(|\\)| )*#';
$chistka = '#((\\-|\\(|\\)| )*){10}#';
foreach ($arr as $input){
if(preg_match($check, $input)){
	echo "Верно\n";
}else{
	echo"Ошибка\n";
}

$output1 = preg_replace($zamena, "8", $input);
$outputFinal = preg_replace($chistka, "", $output1);
echo $outputFinal."\n";}
