|
Posted by "Dan Baker" on 08/29/05 17:51
"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
Navigation:
[Reply to this message]
|