Page 1 of 1

how do i delete a certain line or from one po....

Posted: Tue Mar 06, 2007 8:15 pm
by giarkcom
how do i delete a certain line or from one point to another in a string?
like

Code: Select all

<?xml decare thingy>
<deletefromhere>blah blah blah<tohere></deletefromhere></tohere>
<ordeletethisline>blah blah blah</deletethisline>
</xml thingy>
i did search the internet and didnt find anything
so any suggestions would be great!

ty,
-kraig

Posted: Tue Mar 06, 2007 9:29 pm
by hawleyjr
That example isn't very helpful. What do you want your output to look like?

Posted: Tue Mar 06, 2007 9:59 pm
by giarkcom
i just want to delete a certain line of a string or delete from one character to another

Posted: Tue Mar 06, 2007 11:05 pm
by dude81
If you already know the certain line of the string, you can use regular expression functions like preg_split()

Posted: Tue Mar 06, 2007 11:22 pm
by Kieran Huggins
str_replace('replace this with','',$input);

Posted: Thu Mar 08, 2007 9:07 pm
by giarkcom
i need to delete a line that changes all the time but has the same opening and closing
i need to delete that line

Posted: Fri Mar 09, 2007 7:09 am
by Jenk
Be more specific, and post what code you have already tried. Please do not post your entire script, only the section relevant to what you are trying to achieve.

Posted: Fri Mar 09, 2007 8:27 am
by feyd
2 × substr()

:?:

Posted: Fri Mar 09, 2007 8:41 am
by Kieran Huggins

Posted: Fri Mar 09, 2007 8:44 am
by superdezign
Well if you know the beginning and end, just use a regular expression.

Posted: Fri Mar 09, 2007 7:35 pm
by giarkcom

Code: Select all

<?php 
$ch = curl_init("url here");
curl_setopt($ch, CURLOPT_HEADER, 0);
curl_setopt($ch, CURLOPT_RETURNTRANSFER, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 0);
curl_setopt($ch, CURLOPT_REFERER, "url here");
$data = curl_exec($ch);
curl_close($ch); 
$data = Preg_replace('<lastBuildDate>', ' ',$data);

echo $data;
?>
i need to delete from the start to the end
it is always in the same line but the date changes a lot
'<lastBuildDate>Sat, 10 Mar 2007 00:02:01 +0100</lastBuildDate>'

Posted: Fri Mar 09, 2007 8:21 pm
by feyd

Posted: Tue Mar 13, 2007 7:25 pm
by giarkcom
thank you it worked feyd