如何在php中显示单词拼写列表。示例
$word=bat;
if a=angry
b=beautiful
t=thin
echo $word;
result
b=beautiful
a=angry
t=thin
答案 0 :(得分:1)
如果我理解正确,你应该有单词数组,并将你的单词用作Char
数组。所以最后,我建议,像这样:
function spell_word($word){
$spell_words = array("a"=>"angry", "b"=>"beautiful", "t"=>"thin" );
$result = array();
for( $index=0; $i < strlen( $word ); $i++ ){
$result[] = array( "letter"=> $word[i], "word" => $spell_words[$word[i]]);
}
return $result;
}
var_dump(spell_word("bat"));