Re: search

From: Date: Tue, 03 Jul 2001 12:57:05 +0000
Subject: Re: search
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-55980@lists.php.net to get a copy of this message
On Tue, 3 Jul 2001, Tom Carter wrote: > Rather than trying to break it into an array, you can examine the rightmost > character as follows > > $search="dogs"; > if(substr($search,-1)=='s') $search=substr($search,0,-1); OK, thanks. I am already breaking input search string into an array using a ',' as the seperator. Then I loop while there are elements in this new array and build the search query. Thanks again! Ajdin > > This checks if the last character is an s and if it is then set search to > the same string but without the s.. note, does not handle multiple word > queries.. for this you would need to break the string into words (something > you would probably have to do anyway) and do this for each of those... > > For more info on substr seet http://php.net/substr > ----- Original Message ----- > From: "AJDIN BRANDIC" <abrandic@coventry.ac.uk> > To: <php-general@lists.php.net> > Sent: Tuesday, July 03, 2001 11:10 AM > Subject: [PHP] search > > > > Hi all > > > > I've got search facility (php-mysql) which is very simple. If i search > > for 'dog' it will find any records containing words 'dog' or > > 'dogs' or > > 'dogowner' etc. But if I search for 'dogs', words 'dog' and > > 'dogowner' > > will not be found. This is a classic case so there must be a solution to > > it but I cannot find one. I tried to do something like > > if word is 'dogs' then I do the search, > > then break word 'dogs' into an array and check if the last element is an > > 's'. If it is remove it, reconstrust the string,which will give 'dog', > > and do search for that too. > > Then display results. Well I connot find a way of breaking a string into > > an array. How do I break 'mynameis' into an array of 8 elements? > > This has got loopholes but still it is better than what I have now. > > > > Thanks > > > > Ajdin > > > > -- > > PHP General Mailing List (http://www.php.net/) > > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > > For additional commands, e-mail: php-general-help@lists.php.net > > To contact the list administrators, e-mail: php-list-admin@lists.php.net > > > > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, e-mail: php-general-unsubscribe@lists.php.net > For additional commands, e-mail: php-general-help@lists.php.net > To contact the list administrators, e-mail: php-list-admin@lists.php.net > >

« previous php.general (#55980) next »