Forum Moderators: coopster

Message Too Old, No Replies

Parsing

         

turbohost

11:16 am on Jun 16, 2004 (gmt 0)

10+ Year Member



Hi,

I've got a problem building a script to parse text from a text file. Everything works great for unique strings of text, but there also strings in the text file which are not unique.

E.g. the text file contains the following text "bla blaa text=bloeb1 blabla text=bloeb2 bla"

I want to extract the 'text' variables (with values bloeb1 and bloeb2) from this text file but I don't know how much text variables are present in the file. So, it's possible that there is also a bloeb3 or a bloeb10.

How can I solve this? Can I use the foreach statement?

Philip

IanKelley

8:03 pm on Jun 16, 2004 (gmt 0)

WebmasterWorld Senior Member 10+ Year Member Top Contributors Of The Month



First split (explode) the file on spaces.

Then loop through the resulting array searching for '='.

If found split the string on the equal sign and assign the second resulting variable to your results array.