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 5 of 5
  1. #1
    New Coder
    Join Date
    Jun 2008
    Location
    Vista, CA
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts

    deleting text from a string stored in a variable

    I use this code to get the line25 souce of dragcave.net
    PHP Code:
    $lines file('http://dragcave.net/user/Christian271');
    $line $lines[25]; 
    I want to delete "<br/><br/>If you would like your own dragons, you'll have to go to the <a href="/">Cave Entrance</a>." from the end, and I don't know how mainy characters there are.
    Last edited by Christian271; 08-13-2008 at 06:30 AM.

  • #2
    Supreme Master coder! _Aerospace_Eng_'s Avatar
    Join Date
    Dec 2004
    Location
    In a place far, far away...
    Posts
    19,291
    Thanks
    2
    Thanked 1,043 Times in 1,019 Posts
    Will this line
    Code:
    <br/><br/>If you would like your own dragons, you'll have to go to the <a href="/">Cave Entrance</a>.
    ever change and is it exactly as typed?

    If so something like this would work
    PHP Code:
    $line str_replace('<br/><br/>If you would like your own dragons, you\'ll have to go to the <a href="/">Cave Entrance</a>.','',$lines[25]); 
    ||||If you are getting paid to do a job, don't ask for help on it!||||

  • Users who have thanked _Aerospace_Eng_ for this post:

    Christian271 (08-13-2008)

  • #3
    New Coder
    Join Date
    Jun 2008
    Location
    Vista, CA
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I get the error "Parse error: syntax error, unexpected T_STRING in /home/a9196005/public_html/test.php on line 7" line 7 is
    PHP Code:
    $line str_replace('<br/><br/>If you would like your own dragons, you'll have to go to the <a href="/">Cave 

  • #4
    New Coder
    Join Date
    Jun 2008
    Location
    Vista, CA
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    I see the problem my file manager is deleting the slash!

  • #5
    New Coder
    Join Date
    Jun 2008
    Location
    Vista, CA
    Posts
    59
    Thanks
    3
    Thanked 0 Times in 0 Posts
    Got it working! Thanks so much for the code!


  •  

    Posting Permissions

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