RE: [PHP-DB] Searching a file for text surrounded by brackets

From: Date: Wed, 16 Jul 2003 10:35:17 +0000
Subject: RE: [PHP-DB] Searching a file for text surrounded by brackets
Groups: php.db 
Request: Send a blank email to php-db+get-29277@lists.php.net to get a copy of this message
> -----Original Message----- > From: Jamie Saunders [mailto:phpdev@mediacdcards.net] > Sent: 16 July 2003 11:20 > > Hi, I need a way of searching a file for text between two > brackets, below > is an example of a couple of lines from the file I'm searching: > > <tr><td><font size="2">{L_LOGIN}</font></td></tr> > <tr><td><font > size="2">{L_LOGOUT}</font></td></tr> > > So I'll need to search the above for text between the '{' and > '}' brackets > and read each into an array. preg_match_all() (see http://www.php.net/preg_match_all) should do what you want -- something like: preg_match_all('/{([^}])+}/', $file_contents, $matches); should give you an array of matched tags (excluding the braces) in $matches[1]. Cheers! Mike --------------------------------------------------------------------- Mike Ford, Electronic Information Services Adviser, Learning Support Services, Learning & Information Services, JG125, James Graham Building, Leeds Metropolitan University, Beckett Park, LEEDS, LS6 3QS, United Kingdom Email: m.ford@lmu.ac.uk Tel: +44 113 283 2600 extn 4730 Fax: +44 113 283 3211

« previous php.db (#29277) next »