Remove special chars from URL

Posted by John Jones on Stack Overflow See other posts from Stack Overflow or by John Jones
Published on 2010-04-22T09:22:57Z Indexed on 2010/04/22 9:23 UTC
Read the original article Hit count: 192

Filed under:
|

Hi,

I have a product database and I am displaying trying to display them as clean URLs, below is example product names:

PAUL MITCHELL FOAMING POMADE (150ml) American Crew Classic Gents Pomade 85g Tigi Catwalk Texturizing Pomade 50ml

What I need to do is display like below in the URL structrue:

www.example.com/products/paul-mitchell-foaming-gel(150ml)

The problem I have is I want to do the following:

  1. Remove anything with braquets(and the braquets)
  2. Remove any numbers next to g or ml e.g. 400ml, 10g etc...

I have been banging my head trying different string replaces but cant get it right, I would really appreciate some help.

Cheers

© Stack Overflow or respective owner

Related posts about php

Related posts about string-manipulation