Reply to Re: sscanf() not returning info

Your name:

Reply:


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

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация