Ian Truelsen wrote:
I am trying to parse out a file using an array. I load each line into a
separate key in the array and then do transforms on the individual
lines.

What I am looking to do is to test each for a keyword so that I can know
which entry contains the data that I need and can get the data from the
correct line.

For example, I have the following line:

Wind: from the SW (230 degrees) at 3 MPH (3 KT):0

What I want to do is to identify the line by 'Wind'. However, using
array_search requires that I match the complete content of the line
exactly, which I can't do, as I don't know the exact data.

Is there any way to get array_search to find a partial match? Or is
there another command that I can use to do this?

You can use explode() and split the line into its parts (by using " " as the delimiter). Then the first element will be Wind: and you can check for that.


You could also try any of the regex functions to do the same thing.

--
Burhan Khalid
phplist[at]meidomus[dot]com
http://www.meidomus.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to