Escriba un programa para comparar tres archivos en php

<?php 

function mb_str_split($str, $count){
	$leng = strlen($str)/3; //中文长度
	$arr = array();
	for ($i=0; $i < $leng; $i+=$count) {
		$arr[] = mb_substr($str, $i, $count);
	}
	return $arr;
}

function mb_str_replace($arr){
	$find = array(",",",",'、',';','。'," ",";"," ");
	$re = '@';
	$res = explode('@',str_replace($find,$re,$arr));
	
	return $res;
}

$at = file_get_contents('a.txt');
$bt = file_get_contents('b.txt');
$ct = file_get_contents('c.txt');


$ay = mb_str_replace($at);
$by = mb_str_replace($bt);
$cy = mb_str_replace($ct);

//echo $at;
//var_dump($ay);exit;


echo '-----------------A和B对比-------------------------'.'<br />';
foreach($ay as $av){
	foreach($by as $bv){
		if($av == $bv){
			echo $bv.'<br />';
			break;
		}
	}
}

echo '-----------------A和C对比-------------------------'.'<br />';
foreach($ay as $av){
	foreach($cy as $cv){
		if($av == $cv){
			echo $av.'<br />';
			break;
		}
	}
}

echo '-----------------C和B对比-------------------------'.'<br />';
foreach($cy as $cv){
	foreach($by as $bv){
		if($cv == $bv){
			echo $bv.'<br />';
			break;
		}
	}
}

Supongo que te gusta

Origin blog.csdn.net/qq_26875961/article/details/130229619
Recomendado
Clasificación