Re: uniq string function?

From: Date: Wed, 05 Jul 2000 17:06:52 +0000
Subject: Re: uniq string function?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-5006@lists.php.net to get a copy of this message
> I am developing a website that is nearly complete sql. > I want to generate the meta tags based on content of the > sql query returned. Is there a function in php that can > give me the unique words in a string containing for > example: > "baked, black, beans, blackeye, beans, wild, rice, herbs, fit, king, > baked, beans, pineapple, baked, beans, tropical, baked, beans american, > dry, bean, board, online, cookbook" > > so that there are not duplicate meta keywords? For PHP 3: function uniq_words($str) { $arr = explode(',',$str); while(list(,$v)=each($arr)) { $new[trim($v)]=trim($v); } return implode(',',$new); } For PHP 4: function uniq_words($str) { $arr = explode(',',$str); return implode(',',array_keys(array_flip($arr))); } -Rasmus

« previous php.general (#5006) next »