# [EMAIL PROTECTED] / 2007-01-18 12:34:36 +0200:
> I need to strip all characters from the following text string exept the 
> image path...
> 
> "<img width=\"99\" height=\"120\" border=\"0\" 
> src=\"../../images/new/thumps/4123141112007590373240.jpg\" />"...and then 
> store the path to DB. Image path lengh can vary so I guess that I need to 
> extract all characters after     scr=\"    until next    \"    or somethig 
> similar.

This passes with 5.2:

class ImgSrcTest extends Tence_TestCase
{
    private $src, $str, $xml;
    function setUp()
    {
        $this->src = 'fubar.jpg';
        $this->str = sprintf(
            '<img width="99" height="120" border="0" src="%s" />',
            $this->src
        );
        $this->xml = new SimpleXmlElement($this->str);
    }
    function testReturnsAttributeAsSimpleXMLElements()
    {
        return $this->assertEquals('SimpleXMLElement', 
get_class($this->xml['src']));
    }
    function testCastToStringYieldsTheAttributeValue()
    {
        return $this->assertEquals($this->src, strval($this->xml['src']));
    }
}

-- 
How many Vietnam vets does it take to screw in a light bulb?
You don't know, man.  You don't KNOW.
Cause you weren't THERE.             http://bash.org/?255991

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

Reply via email to