i want compare 2 strings having same number of words , same contents opposite in sequence.
str1 = first day of spring str2 = day of first spring or
str2 = day first spring of the above strings same in contents different in order. answer true in these situations otherwise false.
first split both strings explode() in array posisble difference.
<?php $str1 = 'first day of spring'; $str2 = 'day of first spring'; $array1 = explode(" ", $str1); $array2 = explode(" ", $str2); $fulldiff = array_merge(array_diff($array1, $array2), array_diff($array2, $array1)); if($fulldiff > 0){ echo 'false'; }else{ echo 'true'; } ?>
Comments
Post a Comment