string problem

Discussion in 'PHP' started by dizyn, May 25, 2008.

  1. #1
    Hello all

    I want to read sting and do some processing.

    for example here is my sample string.
    "this is my test string
    new line"

    I want to read this string and then i want to add a "-" at the end of every line, is there way to do this?

    result should be like this:
    "this is my test string-new line"


    thank you
    dizyn
     
    dizyn, May 25, 2008 IP
  2. krakjoe

    krakjoe Well-Known Member

    Messages:
    1,795
    Likes Received:
    141
    Best Answers:
    0
    Trophy Points:
    135
    #2
    $string = str_replace( "\n", "-\n", $string );
    PHP:
     
    krakjoe, May 25, 2008 IP