Re: Get value between 2 strings

From: Date: Mon, 17 Nov 2003 07:32:54 +0000
Subject: Re: Get value between 2 strings
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-169896@lists.php.net to get a copy of this message
This should do the trick: $line = "I want the value between word ONE and word TWO. Please return it..."; preg_match('/ONE(.*)TWO/i', $line, $ret); print_r($ret); "Matt Palermo" <webmaster@sweetphp.com> wrote in message news:20031117062712.35440.qmail@pb1.pair.com... > Hello. I was wondering if anyone knew of a function to get the value > between 2 strings. For example, lets say I have the following line: > > $line = "I want the value between word ONE and word TWO. Please return > it..."; > > Now, I want to get everything between "ONE" and "TWO". In this example it > should return the value " and word ". Is there some sort of function I > could use to easily do this? Please let me know if you have any ideas. > > Thanks, > > Matt

« previous php.general (#169896) next »