Howdy, Stranger!

It looks like you're new here. If you want to get involved, click one of these buttons!

Categories

Welcome to the new platform of Programmer's Heaven! We apologize for the inconvenience caused, if you visited us from a broken link of the previous version. The main reason to move to a new platform is to provide more effective and collaborative experience to you all. Please feel free to experience the new platform and use its exciting features. Contact us for any issue that you need to get clarified. We are more than happy to help you.

new lines

CrushCrush Posts: 43Member
i have this db with some text thais wrapped. (with enters)
in asp i used to replace vbcrlf with br, but how to do it in php, so the text displays qwrapped in html?

Comments

  • ManningManning Posts: 1,621Member
    : i have this db with some text thais wrapped. (with enters)
    : in asp i used to replace vbcrlf with br, but how to do it in php, so the text displays qwrapped in html?

    vbcrlf is just a constant for the CR and LF characters. In PHP (among other languages), CR and LF are represented by
    and
    respectively.

    So you could replace "
    " with "
    ". If that doesn't work, your data might be wrapped with only one of the two, so in that case you could also try just "
    " or "
    ".

    If the line endings could be different for each record so you want a foolproof way to work with them all, try this:

    $strText = str_replace("
    ", "
    ", $strText);
    $strText = str_replace("
    ", "
    ", $strText);
    $strText = str_replace("
    ", "
    ", $strText);

    It's inefficient since it takes 3 calls to str_replace, but it'll work with any combination of CR and LF. A regular expression could do it in 1 call, but I'm rusty with those :)
  • CrushCrush Posts: 43Member
    : $strText = str_replace("
    ", "", $strText);
    : $strText = str_replace("
    ", "", $strText);
    : $strText = str_replace("
    ", "", $strText);
    :

    thank you veryu much for the info... it works...
    but i have another question:
    i want to search the access database with sql.
    i have a string from a form and i want to search a specific table.
    i tried "where txt like '%".$str."%'", but it did not work.
    it only returned rexsults if the txt column was exacly like $str.
    why is this happening? in asp everything was ok. :(

    and another thing...
    i was searching for a nice rich text editor for my cms. i found one, but it was crappy, so i made my own.
    i seem to need javascript to insert some text in a textarea with a buttonclick.
    maybe you know some links, where this info is available or even a nice, friendly, light rt editor? thank you...
  • ManningManning Posts: 1,621Member
    : : $strText = str_replace("
    ", "", $strText);
    : : $strText = str_replace("
    ", "", $strText);
    : : $strText = str_replace("
    ", "", $strText);
    : :
    :
    : thank you veryu much for the info... it works...
    : but i have another question:
    : i want to search the access database with sql.
    : i have a string from a form and i want to search a specific table.
    : i tried "where txt like '%".$str."%'", but it did not work.
    : it only returned rexsults if the txt column was exacly like $str.
    : why is this happening? in asp everything was ok. :(

    I'm not sure why that's happening. Maybe try outputting the SQL string before executing it. It's possible that % is a special character to PHP, so you have to escape it with . Like:

    "where txt like '%".$str."%'"

    But if that's not it, I haven't got a clue what it might be.

    : i was searching for a nice rich text editor for my cms. i found one, but it was crappy, so i made my own.
    : i seem to need javascript to insert some text in a textarea with a buttonclick.
    : maybe you know some links, where this info is available or even a nice, friendly, light rt editor? thank you...

    No, I've never looked at any of those richtext editors. Just searching on Google is all I can suggest.
Sign In or Register to comment.