Re: Seek for a value in a html file ...

From: Date: Wed, 09 Oct 2002 12:10:22 +0000
Subject: Re: Seek for a value in a html file ...
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-119414@lists.php.net to get a copy of this message
Bård tommy nilsen wrote: > I want to read the contents from a html file to a pointer, and seek > for > A value, and return it .... > > The text under is an example, and I want to get the 2505 value to be > returned. > Eks. $id = '2505' > > (<a onmouseover="window.status='show text';return true;" > href="javascript:get(2505);"> Try something like this: $content = @file( '<filename>' ); $pattern = "/a onmouseover=\"window.status='show text';return true;\"> href=\"javascript:get(.*);/"; $result = @preg_grep( $pattern, $content ); The $result variable is an array, where the elements are all the matching lines from the $content array, which is your inputfile. You can then filter out the value you want using strpos, strrpos and substr. HTH Erwin

« previous php.general (#119414) next »