Dave Carrera wrote:

$string = "This is a test string to <title>SHOW ONLY THIS BIT</title> of the
string";

I have tried strpos, str_replace and other string manipulation things but I
cant get my head around how to achieve showing the text with the
<title></title> tags of the string.

Any help is appreciated and I thank you in advance for any help given.

$b = strpos($str,'<title>')+7; $l = strpos($str,'</title>') - $b; $m = substr($str,$b,$l);

Sure, you can use regular expressions, but there's not really a need unless this gets more complex. Even though you're executing more code with this solution, it'll be faster than preg_match() (go ahead and benchmark it).

--
---John Holmes...

Amazon Wishlist: www.amazon.com/o/registry/3BEXC84AB3A5E/

php|architect: The Magazine for PHP Professionals – www.phparch.com

--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to