Re: finding a substring

From: Date: Sat, 17 Jul 2004 00:15:40 +0000
Subject: Re: finding a substring
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-190784@lists.php.net to get a copy of this message
preg_match_all('/value="(.*?)"/', file_get_contents('textFile.txt'), $matches); print_r($matches[1]); On Fri, 16 Jul 2004 18:08:12 -0600, C.F. Scheidecker Antunes <nando@antunes.eti.br> wrote: > Hello all, > > I need to read lines within a text file that might have a " > value='somevalue' " string the position of "value=" varies from line > to > line but there's only one "value=" in each line. > > So what I need to do is to parse the file and find the "value=" and put > their values in an array. > > Suposse I have the following text file with 3 lines : > > snLADEFEFfdgvalue="1234"rwgjngrgj > value="23456"gkerlgwg > 132fngdhbvalue="5678"bfl928 > > I would like to get an array like this: > > array[0] = 1234; > array[1] = 23456; > array[2] = 5678; > > The value is delimited always by double quotes but its position on the > line varies. I need to extract these values and put them on a string. > > Any ideas or help is appreciated. > > Thanks in advance. > > -- > PHP General Mailing List (http://www.php.net/) > To unsubscribe, visit: http://www.php.net/unsub.php > > !DSPAM:40f86d1f101301866793913! > > -- DB_DataObject_FormBuilder - The database at your fingertips http://pear.php.net/package/DB_DataObject_FormBuilder paperCrane --Justin Patrin--

« previous php.general (#190784) next »