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);
?>
br /> "http://www.w3.org/TR/xhtml11/DTD/xhtml11.dtd">
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);
?>
word | frequency |
|
|
回复讨论(解决方案)
sort($sorted_keys);
foreach ($sorted_keys as $word) {
?>
上一篇: Oracle DB删除表_MySQL
下一篇: sqlite 数据库连接类