Forum Moderators: coopster
$variable = "<a href=\"www.example.com/test.php?var=whatever\">link text</a>";
Now the part that I need to trim out of the string is:
href=\"www.example.com/test.php?var=whatever\">";
Now the content of var= will change in legnth, so I can't do a simple right trim and left trim. I mean since the first part of the website up to var= is a constant, I could cut all that off I suppose, but what about getting rid of the back side? The ">link text</a> .. Which is also variable in legnth? I am thinking too hard on it I think.
Any thoughts/suggestions appreciated!
-- Zak
1) Take string poision of starting segment in the main string. = x
2) Take string position of ending segment in the main string. =y
3) remove everything between x and y
string="<a href=\"www.example.com/test.php?var=whatever\">link text</a>";
x= position of [var=]
y= position of [\">]
take left part of the string from 0 to x position
take right part of string from y to last position
concatinate them
and it's done
;)