preg_replace Issue?

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • ziycon
    Contributor
    • Sep 2008
    • 384

    preg_replace Issue?

    I have the below preg_replace string and i want it to remove the comma character as currently the comma is being replaced with a dash(-)??

    preg_replace('#[^a-zA-Z0-9]+#','-',$link)
  • Markus
    Recognized Expert Expert
    • Jun 2007
    • 6092

    #2
    Originally posted by ziycon
    I have the below preg_replace string and i want it to remove the comma character as currently the comma is being replaced with a dash(-)??

    preg_replace('#[^a-zA-Z0-9]+#','-',$link)
    You'd need a seperate function for that.

    Code:
    preg_replace('#[^a-zA-Z0-9]+#', '-', str_replace(',', '', $link));
    Notice the str_replace().

    Comment

    • ziycon
      Contributor
      • Sep 2008
      • 384

      #3
      Thanks for that, got it sorted.

      Comment

      • Markus
        Recognized Expert Expert
        • Jun 2007
        • 6092

        #4
        Originally posted by ziycon
        Thanks for that, got it sorted.
        You're welcome.

        Mark.

        Comment

        Working...