replace comma with space

Posted on 2006-04-20
Last Modified: 2008-01-16
how do i replace a comma, a carrage return, new line, a tab into a blank space all in once.

str_replace and preg_replace.?

str_replace works for only one.  i have

$Comments = str_replace(",", "", $row_orders_status_history["comments"]);
Question by:tgatif

    Author Comment

    fixed with the function.
    function filter_text($text) {
    $filter_array = array(",", "\r", "\n");
    return str_replace($filter_array,"",$text);
    LVL 2

    Accepted Solution

    The above example didn't include tab removal, here is the updated version along with example/usage code:

    $my_text="This is my text, there is a comma,\rblah blah\nblah blah\ttabbed in here\tand here\n";

    function replace_chars($input)
          return str_replace($filter,"",$input);

    print replace_chars($my_text);

    Featured Post

    6 Surprising Benefits of Threat Intelligence

    All sorts of threat intelligence is available on the web. Intelligence you can learn from, and use to anticipate and prepare for future attacks.

    Join & Write a Comment

    Developers of all skill levels should learn to use current best practices when developing websites. However many developers, new and old, fall into the trap of using deprecated features because this is what so many tutorials and books tell them to u…
    Things That Drive Us Nuts Have you noticed the use of the reCaptcha feature at EE and other web sites?  It wants you to read and retype something that looks like this.Insanity!  It's not EE's fault - that's just the way reCaptcha works.  But it is …
    The viewer will learn how to dynamically set the form action using jQuery.
    This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.

    754 members asked questions and received personalized solutions in the past 7 days.

    Join the community of 500,000 technology professionals and ask your questions.

    Join & Ask a Question

    Need Help in Real-Time?

    Connect with top rated Experts

    16 Experts available now in Live!

    Get 1:1 Help Now