PHP'de sonsuz derinlikte menü yapmak için düzgün bir tablo yapısı ve çok basit bir recursive fonksiyon yeterli. Tablo Yapısı CREATE TABLE `category` ( `sid` int(12) unsigned NOT NULL auto_increment, `module` set('estate','cars') collate utf8_bin NOT NULL, `parentId` int(6) NOT NULL, `title` varchar(255) collate utf8_bin NOT NULL, `isDefault` int(1) NOT NULL default '1', PRIMARY KEY (`sid`) ) ENGINE=MyISAM DEFAULT CHARSET=utf8 COLLATE=utf8_bin AUTO_INCREMENT=14 ; INSERT INTO `category` VALUES (1, 0x657374617465, 0, 0x536174c4b16cc4b16b20456d6c616b, 1); INSERT INTO `category` VALUES (2, 0x657374617465, 1, 0x45766c6572, 1); INSERT INTO `category` VALUES (3, 0x657374617465, 1, 0xc4b0c59f7965726c657269, 1); INSERT INTO `category` VALUES (4, 0x657374617465, 1, 0x417273616c6172, 1); INSERT INTO `category` VALUES (5, 0x657374617465, 0, 0x4b6972616cc4b16b20456d6c616b, 1); INSERT INTO `category` VALUES (6, 0x657374617465, 5, 0x45766c6572, 1); INSERT INT...
bugrakaan [at] gmail.com tarafından hazırlanmış ve daha önceden AdobeTurk sitesinde yayınlanmış olan scriptin tarafımdan geliştirilmiş/sadeleştirilmiş hali.
// php ile doviz kuru
// e : bugrakaan [at] gmail.com
// edit : goktug.ozturk [at] hurbilisim.com
$currency = array( "USD" => "", "EUR" => "" );
$convert = array( "isim" => "I",
"forexbuying" => "A",
"forexselling" => "S",
);
$content = file_get_contents( "http://www.tcmb.gov.tr/kurlar/today.xml" );
echo $content;
foreach( $currency as $code => $arr )
{
preg_match( "'(.*) 'Uis", $content, $crst );
foreach( $convert as $field => $value )
{
preg_match( "'<" . $field . ">(.*)" . $field . ">'Uis", $crst[2], $frst );
$currency[$code][$value] = $frst[1];
}
}
echo "Dolar Alış : {$currency['USD']['A']}"
. "Dolar Satış : {$currency['USD']['S']}"
. "Euro Alış : {$currency['EUR']['A']}"
. "Euro Satış : {$currency['EUR']['S']}";
?>
Yorumlar