欢迎您访问程序员文章站本站旨在为大家提供分享程序员计算机编程知识!
您现在的位置是: 首页  >  后端开发

php table循环 问题很简单 求帮助

程序员文章站 2022-06-01 10:17:40
...
怎样table循环将它们输出啊,现在运行结果就一个you 3


br /> "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) {
?>