Re: ereg
| From: | Jason Wong | Date: | Fri, 03 May 2002 04:58:28 +0000 |
| Subject: | Re: ereg | ||
| References: | 1 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-95825@lists.php.net to get a copy of this message | ||
On Friday 03 May 2002 12:51, Jason Soza wrote:
> Hoping someone can help me here. I'm working with someone else's code and
> I'm not familiar with ereg_replace(), can someone provide me an alternative
> to the following?
>
> ereg_replace("[^a-z0-9._]", "",
> ereg_replace (" ", "_",
> ereg_replace("%20", "_",
> strtolower($original_name))));
>
> Basically, I want to enter $original_name and have it come out $new_name,
> converting all spaces to underscores, upper to lowercase, and whatever that
> first line does. :)
>
> I've read through the manual and what I got was that preg_replace() is
> probably faster... Anyhow, I looked up preg_replace() and as a newbie to
> PHP, the given examples look like a language all their own.
What you're doing is not particularly complicated and can be done using
str_replace().
--
Jason Wong -> Gremlins Associates -> www.gremlins.com.hk
Open Source Software Systems Integrators
* Web Design & Hosting * Internet & Intranet Applications Development *
/*
America, how can I write a holy litany in your silly mood?
-- Allen Ginsberg
*/