|
Posted by timslavin on 07/27/06 03:42
Hi,
I'm trying to do something with PHP and I'm not 100% familiar with PHP
as I am with VBScript. So if you could bear with me on what is likely a
stupid question, I'd appreciate it!
I have a chunk of text with a variety of tags inside the text. I want
to perform the following process to this chunk of text:
First, I want to grab data between two markers that I define (e.g.
<start> ... data here ... </start> and strip of the text before the
first marker (<start> in this example) and after the second marker
(</start>) in this example. That would leave me with the "... data here
...." chunk with my markers either included (worst case) or removed
(best case, saving me the third step below).
Is this one PHP function or two functions? I see that strstr will get
me everything to the right of <start> but I cannot figure out how to
remove everything to the right of </start> so that I only have the data
chunk I want (what's between these two markers).
Second, I want to substitute values for values found in the data chunk.
I know str_replace does that just fine.
Third, I then want to strip out the markers from my data chunk. The
<start> marker has elements to it (e.g. limit=) so I'd need something
that would grab everything from <start to the close of the > bracket
(e.g. remove <start limit=1>) to remove it from my data chunk. And
finally I would then want to remove the </start> marker from my data
chunk.
Is this do-able in PHP with a couple functions? Or does it require lots
of string manipulation and lots of functions? Or is it impossible?
Thanks in advance for any insight or pointers to PHP string functions
that'll help!
Tim
Navigation:
[Reply to this message]
|