•
•
•
•
What is DaniWeb IT Discussion Community?
You're currently browsing the PHP section within the Web Development category of DaniWeb, a massive community of 403,516 software developers, web developers, Internet marketers, and tech gurus who are all enthusiastic about making contacts, networking, and learning from each other. In fact, there are 3,853 IT professionals currently interacting right now! Registration is free, only takes a minute and lets you enjoy all of the interactive features of the site.
Please support our PHP advertiser: Lunarpages PHP Web Hosting
Views: 467 | Replies: 4
![]() |
•
•
Join Date: Jun 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
Hello you PHP Community! I am looking to make an automatic meta keyword generator based on an array of phrases. It is more my site that is under construction, PHPMine. Go to the "Q and A" section and you'll see a series of questions there, five in total. right now the system simply grabs all the words there, filters though common words, and then spits out the words as keywords. I would like some advice on how to set it up in this way:
maybe someone has already cooked up this nasty script. thanks in advance guys!
- puts all the words in an array and counts their frequency
- creates an array of two words phrases and counts their frequency
- does the same for 3 word phrases
- spits out the top 25 keywords from the array generated
maybe someone has already cooked up this nasty script. thanks in advance guys!
•
•
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 601
Reputation:
Rep Power: 2
Solved Threads: 53
This is how I would generate those arrays
php Syntax (Toggle Plain Text)
//$keywordsarray is the array that contains said keywords $twowordphrases = array(); //generate two word phrases for($i = 0; $i < count($keywordsarray); $i += 2) { if(isset($keywordsarray[$i + 1])) { $twowordphrases[] = $keywordsarray[$i] . " " . $keywordsarray[$i + 1]; } } $threewordphrases = array(); //generate three word phrases for($i = 0; $i < count($keywordsarray); $i += 3) { if(isset($keywordsarray[$i + 2])) { $threewordphrases[] = $keywordsarray[$i] . " " . $keywordsarray[$i + 1] . " " . $keywordsarray[$i + 2]; } }
Last edited by R0bb0b : Jun 29th, 2008 at 4:27 pm.
“Be who you are and say what you feel because those who mind don't matter and those who matter don't mind.” - Dr. Seuss
•
•
Join Date: Jun 2008
Posts: 2
Reputation:
Rep Power: 0
Solved Threads: 0
ah i see and now i cycle through the array and see how many times that phrase comes up right? AWESOME! I think i was trying to do this all through one pass but I'll have to create 4 loops, one that create the phrases ( the snippet you created) and then I'll have to go through each and count the number of times the phrase is found. right?
•
•
Join Date: Jun 2008
Location: Phoenix, AZ
Posts: 601
Reputation:
Rep Power: 2
Solved Threads: 53
•
•
•
•
This is how I would generate those arrays
php Syntax (Toggle Plain Text)
//$keywordsarray is the array that contains said keywords $twowordphrases = array(); //generate two word phrases for($i = 0; $i < count($keywordsarray); $i += 2) { if(isset($keywordsarray[$i + 1])) { $twowordphrases[] = $keywordsarray[$i] . " " . $keywordsarray[$i + 1]; } } $threewordphrases = array(); //generate three word phrases for($i = 0; $i < count($keywordsarray); $i += 3) { if(isset($keywordsarray[$i + 2])) { $threewordphrases[] = $keywordsarray[$i] . " " . $keywordsarray[$i + 1] . " " . $keywordsarray[$i + 2]; } }
I wouldn't jump 2, and 3 words though. Just have one loop, and then take 1,2,3 words from the current word and put them into lists. That way you get each possible phrase. The current misses those that don't start with multiples of 2 and 3.
Probably good to also discard any keyword phrase that includes common words, or words less then or equal to 2 maybe 3 chars.
2 and 3 word phrases won't work so well unless you have a large body of text to compare to so you'd probably want to take your phrases to your database and do the comparison in mysql on an index for your whole site. I know its intensive, but it is worth it if you cache well.
www.fijiwebdesign.com - web design and development and fun
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
Cpanel Email - Let users Register email accounts on your website upon registration
Ajax Chat - Fully browser based chat!
![]() |
•
•
•
•
•
•
•
•
DaniWeb PHP Marketplace
•
•
•
•
Currently Active Users Viewing This Thread: 1 (0 members and 1 guests)
Similar Threads
- Simple ASP.Net Login Page using C# (C#)
- SEO type scripts need eg page rank checker (Existing Scripts)
- SEO Meta Keywords Auto Generator (Search Engine Optimization)
- Understanding ASP classes (ASP Tutorials)
Other Threads in the PHP Forum
- Previous Thread: get indian time in php
- Next Thread: how to use aspell in php


Linear Mode