Hello and welcome to our community! Is this your first visit?
Register
Enjoy an ad free experience by logging in. Not a member yet? Register.
Results 1 to 3 of 3
  1. #1
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts

    substr_replace with the < character?

    If I want to replace a character in a string with the character '<', how do I do this? Anything I try, including escaping like so:
    substr_replace($rs, '\<?', 0 ) causes an error.
    This is what I would like to to do:

    $rs = "1?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";

    $rs = substr_replace($rs, '<?', 0 );
    so that rs will equal:
    <?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>

    G

  • #2
    Master Coder
    Join Date
    Dec 2007
    Posts
    6,682
    Thanks
    436
    Thanked 890 Times in 879 Posts
    Quote Originally Posted by gorilla1 View Post
    If I want to replace a character in a string with the character '<', how do I do this? Anything I try, including escaping like so:
    substr_replace($rs, '\<?', 0 ) causes an error.
    This is what I would like to to do:

    $rs = "1?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>";

    $rs = substr_replace($rs, '<?', 0 );
    so that rs will equal:
    <?xml version=\"1.0\" encoding=\"ISO-8859-1\"?>

    G
    try this:
    PHP Code:
    $rs substr_replace($rs,'<',0,1); 
    best regards

  • #3
    Regular Coder
    Join Date
    Jun 2002
    Posts
    553
    Thanks
    0
    Thanked 0 Times in 0 Posts
    awesome -- thanks -- that did work


  •  

    Posting Permissions

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