おそらくこれが役に立ちます。私はAnantからコメントをフォークしました。
$first_str = "abcdez";
$second_str= "abhdx";
$first_str_array = str_split($first_str);
$second_str_array = str_split($second_str);
$first_count = count($first_str_array);
$second_count = count($second_str_array);
if (($first_count - $second_count) > 0) {
$count = $first_count - $second_count;
unset($first_str_array[$first_count-$count]);
} else if (($second_count - $first_count) > 0){
$count = $second_count - $first_count;
unset($second_str_array[$second_count-$count]);
}
$final_difference = array_diff($first_str_array,$second_str_array);
を示す配列を持つことになります
を動作するはず? –
なぜ '2'ですか? 'c'、' e'、 'z'は2番目の文字列にはありません。 – chris85
@Patrick Mlr。はい。最初の文字列の最初の文字列と2番目の文字列の最初の文字列... –