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

PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!

Moderator: General Moderators

Post Reply
giarkcom
Forum Newbie
Posts: 24
Joined: Thu Nov 09, 2006 8:22 pm

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

Post 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
User avatar
hawleyjr
BeerMod
Posts: 2170
Joined: Tue Jan 13, 2004 4:58 pm
Location: Jax FL & Spokane WA USA

Post by hawleyjr »

That example isn't very helpful. What do you want your output to look like?
giarkcom
Forum Newbie
Posts: 24
Joined: Thu Nov 09, 2006 8:22 pm

Post by giarkcom »

i just want to delete a certain line of a string or delete from one character to another
User avatar
dude81
Forum Regular
Posts: 509
Joined: Mon Aug 29, 2005 6:26 am
Location: Pearls City

Post by dude81 »

If you already know the certain line of the string, you can use regular expression functions like preg_split()
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

str_replace('replace this with','',$input);
giarkcom
Forum Newbie
Posts: 24
Joined: Thu Nov 09, 2006 8:22 pm

Post 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
User avatar
Jenk
DevNet Master
Posts: 3587
Joined: Mon Sep 19, 2005 6:24 am
Location: London

Post 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.
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

2 × substr()

:?:
User avatar
Kieran Huggins
DevNet Master
Posts: 3635
Joined: Wed Dec 06, 2006 4:14 pm
Location: Toronto, Canada
Contact:

Post by Kieran Huggins »

User avatar
superdezign
DevNet Master
Posts: 4135
Joined: Sat Jan 20, 2007 11:06 pm

Post by superdezign »

Well if you know the beginning and end, just use a regular expression.
giarkcom
Forum Newbie
Posts: 24
Joined: Thu Nov 09, 2006 8:22 pm

Post 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>'
User avatar
feyd
Neighborhood Spidermoddy
Posts: 31559
Joined: Mon Mar 29, 2004 3:24 pm
Location: Bothell, Washington, USA

Post by feyd »

giarkcom
Forum Newbie
Posts: 24
Joined: Thu Nov 09, 2006 8:22 pm

Post by giarkcom »

thank you it worked feyd
Post Reply