<?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ÆÄÀÏ¿¡ ¹®Á¦°¡ Àִ°Š°°¾Æ¿ä
. °è¼Ó ´Ù¸¥ ½ÄÀ¸·Î ½ÃµµÇغ¸´Âµ¥µµ Àß ¾ÈµÅ³»¿ä. µµ¿ÍÁÖ¼¼¿ä ¤Ì¤Ì |