Go Back   Dreamweaver Club Forums > Hand Coders Forum > PHP
Register FAQ Members List Search Today's Posts Mark Forums Read

Thread Tools Display Modes
Old 11-24-2011, 03:34 PM   #1
cocoonfx's Avatar
Join Date: Nov 2006
Location: Tamworth,UK
Posts: 576
Default Keyword generation and PHP


I am trying to generate some keywords to form a tag cloud in wordpress. I know there are plugins but I am trying to develop a bit code which can take the words used in the posts.

So far I have the following code which breaks the text into individual words
PHP Code:
$content get_the_content();
$withCounts explode' '$content );
print_r ($withCounts); 
Array ( [0] => This [1] => is [2] => an [3] => example [4] => page. [5] => It's [6] => different [7] => from [8] => a [9] => blog [10] => post [11] => because [12] => it [13] => will [14] => etc....

How do I get rid of the Array ( and the => [] etc... and also I have tried to do an if statement to remove any words smaller than 3 words.

Any pointers please?
cocoonfx is offline   Reply With Quote
Old 11-27-2011, 09:34 PM   #2
davidj's Avatar
Join Date: Sep 2005
Location: The Toon (newcastle upon Tyne)
Posts: 8,256

You will need an algorithm to do this as choosing words based on length wont work. You will pick up words like 'because' or 'example'. You will need to filter on Nouns which are stored in a database.

To remove words of a set length... (Although don't think this is the right tool for the job!)

PHP Code:

foreach($withCounts as $value=>$key){

strlen($value) < 4){



Would you like to learn PHP from me? Check out -> www.codezenith.co.uk
davidj is offline   Reply With Quote

Thread Tools
Display Modes

Posting Rules
You may not post new threads
You may not post replies
You may not post attachments
You may not edit your posts

BB code is On
Smilies are On
[IMG] code is On
HTML code is Off

Forum Jump

All times are GMT. The time now is 12:44 PM.

Powered by vBulletin® Version 3.8.7
Copyright ©2000 - 2018, vBulletin Solutions, Inc.
Copyright 2006 DreamweaverClub.com