Rahul Dev Posted December 9, 2010 Share Posted December 9, 2010 <?php $title = "This is an example of a sentence in a paragraph"; $title_array = explode(" ", $title); // splits the string by string $chr_count = array(); foreach($title_array AS $word){ $chr_count[] = strlen($word); } echo $chr_count[0]; $count = count($title_array); for($i=0; $i<$count; $i++) { ??????? } ?> i want to store the count for every word in the $title, in a variable, but i get an error. Actually i need the count of every word so that i can store every word which has greater than 5 characters in an array variable! Then i would use this variable to compare words in another paragraph to check whether sentences in the other paragraph contain these words. If they contain these words then i would add the sentence to a variable $summary which would make the summary of the original paragraph. Any ideas please? Link to comment https://forums.phpfreaks.com/topic/221101-check-whether-a-word-has-more-than-5-characters/ Share on other sites More sharing options...
OldWest Posted December 9, 2010 Share Posted December 9, 2010 I did not test or read all your code, but on this line: count($title_aray); you are missing an "r" in title_array Link to comment https://forums.phpfreaks.com/topic/221101-check-whether-a-word-has-more-than-5-characters/#findComment-1144832 Share on other sites More sharing options...
Rahul Dev Posted December 9, 2010 Author Share Posted December 9, 2010 Quote I did not test or read all your code, but on this line: count($title_aray); you are missing an "r" in title_array thanx. modified it,but still getting errors! Link to comment https://forums.phpfreaks.com/topic/221101-check-whether-a-word-has-more-than-5-characters/#findComment-1144833 Share on other sites More sharing options...
OldWest Posted December 9, 2010 Share Posted December 9, 2010 Quote Quote I did not test or read all your code, but on this line: count($title_aray); you are missing an "r" in title_array thanx. modified it,but still getting errors! Ok. I don't really understand what you are trying to do or why, so I can't help much. Your description is not very complete. Can you try to clarify exactly what you are trying to do any for what purpose? Link to comment https://forums.phpfreaks.com/topic/221101-check-whether-a-word-has-more-than-5-characters/#findComment-1144834 Share on other sites More sharing options...
Rahul Dev Posted December 9, 2010 Author Share Posted December 9, 2010 Quote Quote Quote I did not test or read all your code, but on this line: count($title_aray); you are missing an "r" in title_array thanx. modified it,but still getting errors! Ok. I don't really understand what you are trying to do or why, so I can't help much. Your description is not very complete. Can you try to clarify exactly what you are trying to do any for what purpose? I need to summarize an article. First i need to store the article's title in a variable. Then i need to check whether the sentences in the article contains the words(The words need to be greater than 5 characters) in the title of the article. Then if the sentences contain those words i would add the sentence to another variable $summary which would make a summary of the original article! Any ideas?? Link to comment https://forums.phpfreaks.com/topic/221101-check-whether-a-word-has-more-than-5-characters/#findComment-1144838 Share on other sites More sharing options...
OldWest Posted December 9, 2010 Share Posted December 9, 2010 This is all I can give you tonight. Good luck with the rest! <?php $title = "This is an example of a sentence in a paragraph"; $title_array = explode(" ", $title); foreach ($title_array as $word) { $chr_count = strlen($word); if ($chr_count > 5) echo "$word - $chr_count <br />"; } ?> Link to comment https://forums.phpfreaks.com/topic/221101-check-whether-a-word-has-more-than-5-characters/#findComment-1144842 Share on other sites More sharing options...
Rahul Dev Posted December 9, 2010 Author Share Posted December 9, 2010 Quote This is all I can give you tonight. Good luck with the rest! <?php $title = "This is an example of a sentence in a paragraph"; $title_array = explode(" ", $title); foreach ($title_array as $word) { $chr_count = strlen($word); if ($chr_count > 5) echo "$word - $chr_count <br />"; } ?> Thanx for your help. Link to comment https://forums.phpfreaks.com/topic/221101-check-whether-a-word-has-more-than-5-characters/#findComment-1144844 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.