Advertisement
Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?
- function postrev_wordcount ()
- {
- global $db, $db_prefix , $config_data, $dir;
- include($dir."language/".$config_data["lang"].".php");
- // traigo todo el texto de cada noticia más el año
- $consulta_noticias = "select year(time) as anio, hometext, bodytext from".$db_prefix." posts where estado = 1;";
- $contador = array("2002" => 0, "2003" => 0, "2004" => 0, "2005" => 0, "2006" => 0, "2007" => 0, "2008" => 0, "2009" => 0, "2010" => 0, "2011" => 0); // total palabras
- $contador2 = array("2002" => 0, "2003" => 0, "2004" => 0, "2005" => 0, "2006" => 0, "2007" => 0, "2008" => 0, "2009" => 0, "2010" => 0, "2011" => 0); // cantidad de posts
- print_r($contador);
- $resultado = $db->sql_query($consulta_noticias);
- while ($row = $db->sql_fetchrow($resultado))
- {
- $anio = $row[anio];
- $bodytext = strip_tags($row[bodytext]);
- $hometext = strip_tags($row[hometext]);
- $total = str_word_count($bodytext) + str_word_count($hometext);
- $contador[$anio] = $contador[$anio] + $total;
- $contador2[$anio] = $contador2[$anio] + 1;
- }
- print_r($contador);
- print_r($contador2);
- }
- ?>
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement