Re: sscanf() not returning info

From: Date: Mon, 29 Aug 2005 14:51:14 +0000
Subject: Re: sscanf() not returning info
References: 1  Groups: php.general 
Request: Send a blank email to php-general+get-221509@lists.php.net to get a copy of this message
"Simon Fredriksson" <simon@lan2k.org> wrote in message news:66.8E.28235.5C7A0134@pb1.pair.com... > Can anyone tell me what is wrong here? > > <?php > $data = "<a class=\"new20030101\" href=\"Zero01.jpg\">Pic > 1</a>"; > $info = sscanf($data,"<a class=\"%s\" > href=\"%s\">%s</a>"); > var_dump($info); > ?> One way to do this is: <?php $data = "<a class=\"new20030101\" href=\"Zero01.jpg\">Pic 1</a>"; sscanf($data,"<a class=\"%s\" href=\"%s\">%s</a>", $class, $href, $text); echo "Class = $class<br>"; echo "href = $href<br>"; echo "test = $text<br>"; ?> Another way is: <?php $data = "<a class=\"new20030101\" href=\"Zero01.jpg\">Pic 1</a>"; list ($class, $href, $text) = sscanf($data,"<a class=\"%s\" href=\"%s\">%s</a>"); echo "Class = $class<br>"; echo "href = $href<br>"; echo "test = $text<br>"; ?> DanB

« previous php.general (#221509) next »