Re: partial match on array_search?

From: Date: Mon, 20 Oct 2003 10:15:51 +0000
Subject: Re: partial match on array_search?
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-166737@lists.php.net to get a copy of this message
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

« previous php.general (#166737) next »