function two_strings_have_same_words_in_different_order($str1, $str2) {
$wordsOfStr2 = explode(" ", $str2);
foreach (explode(" ", $str1) as $str1word) {
if (!in_array($str1word, $wordsOfStr2)) {
return false;
}
}
return true;
}
$str1 = "java c# c c++ python php";
$str2 = "python c++ php java c# c";
if (two_strings_have_same_words_in_different_order($str1, $str2)) {
echo "yes";
} else {
echo "no";
}
/*
run:
yes
*/