<?php
//index.php
require_once('../HTS-Program/algorithms.php');
$word_bank = array('one','two','three','four','five');
$words = array('urof','wto');
for($i=0;$i<count($words);$i++){
for($ii=0;$ii<count($word_bank);$ii++){
find_word($words[$i], $word_bank[$ii]);
}
}
?>
<?php
//algorithms.php file located in ../HTS-Program
function find_word($a, $b){
// $a = scrambled word
// $b = one getting compared to (from the original list)
$a_split = str_split($a);
$b_split = str_split($b);
sort($a_split);
sort($b_split);
$new_a = implode('',$a_split);
$new_b = implode('',$b_split);
if($new_a == $new_b){
echo $b.', ';
}
}
?>
원래는 four, two, 라고 나올줄 알았는데 자꾸 four, 만 나오네요. for loop 이나 제 algorithms.php파일에 문제가 있는거 같아요
. 계속 다른 식으로 시도해보는데도 잘 안돼내요. 도와주세요 ㅜㅜ |