...

View Full Version : Resolved deleting text from a string stored in a variable



Christian271
08-13-2008, 05:42 AM
I use this code to get the line25 souce of dragcave.net

$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.

_Aerospace_Eng_
08-13-2008, 05:43 AM
Will this line

<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

$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]);

Christian271
08-13-2008, 06:21 AM
I get the error "Parse error: syntax error, unexpected T_STRING in /home/a9196005/public_html/test.php on line 7" line 7 is


$line = str_replace('<br/><br/>If you would like your own dragons, you'll have to go to the <a href="/">Cave

Christian271
08-13-2008, 06:26 AM
I see the problem my file manager is deleting the slash!:(

Christian271
08-13-2008, 06:29 AM
Got it working! Thanks so much for the code!:D



EZ Archive Ads Plugin for vBulletin Copyright 2006 Computer Help Forum