SitePoint Sponsor

User Tag List

Results 1 to 7 of 7

Thread: help me

  1. #1
    SitePoint Enthusiast Rami Yacoub's Avatar
    Join Date
    Oct 2004
    Location
    jordan
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Question How Can I Cange This Function From AST To PHP

    function PrepareDataForHTMLRTA(byval strData)

    strData = Replace(strData,"\","\\")
    strData = Replace(strData,"'","\'")
    strData = Replace(strData,"""","\""")
    strData = Replace(strData,vbCrlf,"\n")

    PrepareDataForHTMLRTA = strData

    end function
    Last edited by Rami Yacoub; Dec 1, 2004 at 01:14.

  2. #2
    SitePoint Evangelist elgumbo's Avatar
    Join Date
    Nov 2002
    Location
    North West, UK
    Posts
    545
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Can you post your code?

  3. #3
    SitePoint Enthusiast Rami Yacoub's Avatar
    Join Date
    Oct 2004
    Location
    jordan
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    very smiple

    i want to add text from data base to a rich text editor,
    the rich text editor must take one line as a init value

    the variable come from database like:
    $var="l;ksdjfl;skdjflks
    ;laskdjflk;sdj

    s;dlkfj sl;dkjfl;skdf
    s;dklfj;sldkfj";

    and i need it
    $var="l;ksdjfl;skdjflks ;laskdjflk;sdj s;dlkfj sl;dkjfl;skdf s;dklfj;sldkfj";

    to be accept by my rich text editor

  4. #4
    SitePoint Zealot number7's Avatar
    Join Date
    Jul 2004
    Location
    Virtual City, Neural Networks str. 7
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Use preg_replace to replace new line characters:

    Code:
    $one_line_string = preg_replace("/\n/","",$var);

  5. #5
    SitePoint Enthusiast Rami Yacoub's Avatar
    Join Date
    Oct 2004
    Location
    jordan
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Unhappy it dosn't work

    sorry,
    i try it, but unfotinatly it don't work
    i still have the problem.
    and i try to put /r and it not work

  6. #6
    SitePoint Zealot number7's Avatar
    Join Date
    Jul 2004
    Location
    Virtual City, Neural Networks str. 7
    Posts
    139
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)
    Maybe there is some more special characters. \n works pretty fine for me. Could you investigate what special characters are used for new line in DB ?
    Then you could use such reg-exp syntax:

    Code:
    \xhh
    character with hex code hh

  7. #7
    SitePoint Enthusiast Rami Yacoub's Avatar
    Join Date
    Oct 2004
    Location
    jordan
    Posts
    32
    Mentioned
    0 Post(s)
    Tagged
    0 Thread(s)

    Thumbs up I Find It, Thank You :)

    function onLine($str){
    $tempVar=str_replace ( chr(10),' ', $str ) ;
    $str=str_replace ( chr(13), ' ', $tepVar ) ;
    return $str;
    }

    by using this function your code will be one line
    it's not \n , it's enter char,,,

    any way thank you


Bookmarks

Posting Permissions

  • You may not post new threads
  • You may not post replies
  • You may not post attachments
  • You may not edit your posts
  •