Tycoon Talk
Become a Big fish!
The number 1 forum for online business!
Post topics, ask questions, share your knowledge.
Tycoon Talk is part of Freelancer.com - find skilled workers online at a fraction of the cost.

PHP Forum


You are currently viewing our PHP Forum as a guest. Please register to participate.
Login



Freelance Jobs

Reply
Finding keywords within a string
Old 04-20-2005, 08:08 AM Finding keywords within a string
fambi's Avatar
Ultra Talker

Posts: 339
Trades: 0
PHP Code:
$string "This is the world that we live in.";
$keyword "world";
if(
stristr($item_string $keyword )) echo"$keyword detected"
How can we do that for multiple keywords without creating a loop?
__________________

Please login or register to view this content. Registration is FREE
from a
Please login or register to view this content. Registration is FREE
is easy!
Read this
Please login or register to view this content. Registration is FREE
that uses our
Please login or register to view this content. Registration is FREE
.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
 
Register now for full access!
Old 04-20-2005, 08:17 AM
Kyrnt's Avatar
The Post-Mod Years

Posts: 2,536
Location: Western Maryland
Trades: 0
Without a loop, you will simply have to check each keyword individually. I would suggest dropping the entire functionality to a function so it can quickly be re-used.
__________________
—Kyrnt
Kyrnt is offline
Reply With Quote
View Public Profile Visit Kyrnt's homepage!
 
Old 04-20-2005, 08:19 AM
fambi's Avatar
Ultra Talker

Posts: 339
Trades: 0
Thanks Kyrnt.

I was hoping php had a function that would do this!

Oh Well!
__________________

Please login or register to view this content. Registration is FREE
from a
Please login or register to view this content. Registration is FREE
is easy!
Read this
Please login or register to view this content. Registration is FREE
that uses our
Please login or register to view this content. Registration is FREE
.
fambi is offline
Reply With Quote
View Public Profile Visit fambi's homepage!
 
Old 04-20-2005, 01:20 PM
chrishirst's Avatar
Missing! presumed drunk.

Posts: 42,385
Name: Chris Hirst
Location: Blackpool. UK
Trades: 0
use a regular expression

PHP Code:
if (preg_match("[word1|word2]","this has  word1 or word2 in it")) {
    echo 
"Detected";
    } else {
    echo 
"Not Detected";

this will show "Detected" if one or the other (or both) words in the pattern are matched.
__________________
Chris. ->>
Please login or register to view this content. Registration is FREE
<<-

A foolish consistency is the hobgoblin of little minds
Thought for today:- Is SEO the only industry where all the cowboys are Indians?
chrishirst is offline
Reply With Quote
View Public Profile Visit chrishirst's homepage!
 
Reply     « Reply to Finding keywords within a string
 

Thread Tools Search this Thread
Search this Thread:

Advanced Search

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
Trackbacks are Off
Pingbacks are Off
Refbacks are Off





   
RSS Feed  Feeds: RSS   JS   XML
RSS Feed  Feeds for this forum: RSS   JS   XML



Page generated in 0.72415 seconds with 12 queries