Answered: How to count all the words made by a user in a month?

Post date: 2020-09-24 23:45:45
Views: 114

It can be done with few queries as following.

1) get array of all texts posted by THE USER between 1 month and 2 month. Lets say array name is $words. For example,

DEFINE FUNCTION SOMETHING LIKE THIS:

function get_words_array($userid,$startinterval,$endinterval)

{

$records = qa_db_read_all_assoc(qa_db_query_sub(

"SELECT content

FROM ^posts

WHERE userid = # AND (date_created BETWEEN $ AND $)",

$userid, $startinterval, $endinterval

));

return $records;

}

RUN ABOVE DEFINED FUNCTION TO GET ARRAY OF CONTENTS BY SPECIFIC USER AT SPECIFIC INTERVAL:

$words = get_words_array($userid,$startinterval,$endinterval);

2) convert array ($words) to string and merge them by foreach loop. Assign it to new variable $words_all_string

$words_all_string ='';

foreach ( $words AS $key=>$word) {

$words_all_string .= $word.' '.;

}

3) count words by 

str_word_count($words_all_string);

Please click Here to read the full story.
 
Other Top and Latest Questions:
Buy this little-known pharma stock with more than 80% upside ahead, RBC says
What will it take to get tech stocks rising again? An unemployment rate above 4%
Here's why FEMA has spent about $4 billion to help destroy flood-prone homes
Charles Buhler reactionless drive math error?
Trump trial: Ex-National Enquirer publisher David Pecker is first prosecution witness to testify
Movie: Life Is Sweet
All Elite Wrestling: Dynamite: AEW Dynasty 2024
Fallout: The Trap
Ex-JetBlue CEO Robin Hayes to run Airbus North America
Verizon reports fewer quarterly subscriber losses on flexible plan demand