当前位置:Gxlcms > PHP教程 > phptable循环问题很简单求帮助

phptable循环问题很简单求帮助

时间:2021-07-01 10:21:17 帮助过:5人阅读

怎样table循环将它们输出啊,现在运行结果就一个you 3


"http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">



word_table.php



function splitter($str) {

// Create the empty word frequency array
$freq = array();

// Split the parameter string into words
$words = preg_split("/[ .,;:!?]\s*/", $str);

// Loop to count the words (either increment or initialize to 1)
foreach ($words as $word) {
$keys = array_keys($freq);
if(in_array($word, $keys))
$freq[$word]++;
else
$freq[$word] = 1;
}

return $freq;
} #** End of splitter

// Main test driver

$str = "apples are good for you, or don't you like apples?
or maybe you like oranges better than apples";

// Call splitter

$tbl = splitter($str);
?>








$sorted_keys = array_keys($tbl);
sort($sorted_keys);
foreach ($sorted_keys as $word);
?>






 
word frequency



 



回复讨论(解决方案)

sort($sorted_keys);
foreach ($sorted_keys as $word) {
?>








 

人气教程排行