Re: Get the string between custom delimiters

From: Date: Tue, 01 May 2001 16:14:10 +0000
Subject: Re: Get the string between custom delimiters
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-50956@lists.php.net to get a copy of this message
On Mon, Apr 30, 2001 at 02:06:50PM +0100, Matthew Ralston wrote: > Is there a nice easy function that could be used to get a sub string that > lies in between two other sub strings in one big string. > > For example... get the text that lies in between "<title>" and > "</title>" > (without the quotes) in the code of a web page. > > I'm after a function like: > > string getstring_between_customdelimiters(string source, string > open_delimiter, sting close_delimiter) Regular Expressions are you friends http://www.php.net/manual/en/ref.regex.php <?php $string="whawha <Title>blabla blabla </TITLE> yada"; eregi("<title>(.*)</title>",$string,$result); echo "Before:\"$string\", after \"$result[1]\""; ?> -- Daniel Tryba

« previous php.general (#50956) next »