Welcome Guest, Not a member yet? Register   Sign In
Getting certain keywords from a string ?
#1

[eluser]aquary[/eluser]
I'm implementing my webboard using CI and thinking about using some important words from the thread title as a page keyword. I thought about putting those "important words" I want to look for into an array, then foreach and check if any of them exists in the given string.

Code:
$str="Some thread titile with important words";
function get_key($str){

$key=array("important", "words", "I'm", "looking", "for");
$ret='';
foreach($key as $k){
    if(strpos($str, $k)!==FALSE)
        $ret.=$k.', ';
}
return $ret;
}

The function would return "important, words", and I'll put it in the META tag.

The concept should work, but there are too many words I want to put in the array (more that 50, I guess). The script would take some times to return the keywords.

What do you think about this? Are there any other functions that can do this?

Thanks Smile


Messages In This Thread
Getting certain keywords from a string ? - by El Forum - 05-26-2009, 10:20 PM
Getting certain keywords from a string ? - by El Forum - 05-26-2009, 11:47 PM
Getting certain keywords from a string ? - by El Forum - 05-27-2009, 01:43 AM
Getting certain keywords from a string ? - by El Forum - 05-27-2009, 01:52 AM
Getting certain keywords from a string ? - by El Forum - 05-27-2009, 01:56 AM



Theme © iAndrew 2016 - Forum software by © MyBB