Home >Backend Development >PHP Tutorial >php table循环 问题很简单 求帮助

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

WBOY
WBOYOriginal
2016-06-23 14:06:381049browse

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


nbsp;html PUBLIC "-//w3c//DTD XHTML 1.1 //EN"
  "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)  {
?> 

   


     
 
 
 
   

  
Statement:
The content of this article is voluntarily contributed by netizens, and the copyright belongs to the original author. This site does not assume corresponding legal responsibility. If you find any content suspected of plagiarism or infringement, please contact admin@php.cn