Re: sscanf() not returning info

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



"Simon Fredriksson" <simon@xxxxxxxxx> wrote in message 
news:66.8E.28235.5C7A0134@xxxxxxxxxxxxxxx
> 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

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux