Re: str_replace to ignore commas

From: Date: Tue, 06 Jan 2004 14:50:36 +0000
Subject: Re: str_replace to ignore commas
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-173849@lists.php.net to get a copy of this message
At 15:29 6-1-04, you wrote:
I'm trying to use str_replace to ignore sertain characters from a recordset field and it seems I am having difficulties with ignoring commas and carriage returns. I've gotten the following but when searching for, let's say, New York. When York is at the end of a sentence from a recordset field it is skipped and if it has a comma like York, it is skipped. Any ideas? Here's the code I'm using so far //IGNORED CHARACTERS $replacement = array("\"", "\,", ".", "!", "?"); //CREATE THE ARRAY OF WORDS //STRIP SLASHES, IGNORE CAPS, IGNORE REPLACEMET CHARACTERS //$keywords = form field value $words=explode(" ", stripslashes(strtolower(str_replace($replacement, "", $keywords))));
could the problem be that you explode on " " so the phrase 'New York', having a space, is split up?

« previous php.general (#173849) next »