aaxc Posted July 10, 2011 Report Share Posted July 10, 2011 Sveiki, uzreiz saku, ka es jautaajums ir noobisks. Es te pus nakti njemos un taa arii nesaprotu, kaa pareizi ieguut latvijas bankas valuutu kursus masiivaa. Esmu ticis liidz pasham sakumama: Function myKursi() { // ieguustam kursus, ja shii ir pirmaa reize kad piesleedzamies bankai GLOBAL $BankXML; // links $BankXML = "http://www.bank.lv/vk/xml.xml"; $masiivs = simplexml_load_file($BankXML); foreach (simplexml_load_string($dati) as $virsraksts => $maziivs) { // Apstraadaajam ieguuto masiivu switch ($virsraksts) { // Paarveidojam datumu GERMAN formaataa case "Date": $datums = substr($maziivs[0],6,2).".".substr($maziivs[0],4,2).".".substr($maziivs[0],0,4); break; case "Currencies"; $kursi = $maziivs["Currency"]; foreach (simplexml_load_file($BankXML) as $virsraksts => $maziivs) { echo "<pre>"; print_r($maziivs); echo "</pre>"; } break; } } } Pie "echo" stadijas es dabuunu scriptu objekta formaataa un namaaku to dabuut standarta masiivaa, lai peec tam to apstraadaatu un izvaidotu "excel" tipa tabulaa. Any help? Quote Link to comment Share on other sites More sharing options...
mad182 Posted July 10, 2011 Report Share Posted July 10, 2011 Priekš kam viņu vispār vajag pārveidot par masīvu? Ir taču vienalga, vai drukāt $var['lala'] vai $var->lala Quote Link to comment Share on other sites More sharing options...
daGrevis Posted July 10, 2011 Report Share Posted July 10, 2011 Pie tam vari beigās piespraust $xml = $xml->as_array(); un tas būs masīvs. Ja nevari, tad noteikti vari $xml = (array) $xml;. Masīvs! Ja tā arī nesanāk, tad ignorē Manu postu. Protams, vispār, ja Tev vajag masīvu. Var jau darīt kā M teica. Quote Link to comment Share on other sites More sharing options...
aaxc Posted July 10, 2011 Author Report Share Posted July 10, 2011 (edited) Paldies par padomiem, izdomāju kā. Rīts tomēr gudrāks par vakaru :) Function myKursi() { GLOBAL $BankXML; $dati = simplexml_load_file($BankXML); $datums = $dati->Date; $vDatums = substr($datums,6,2).".".substr($datums,4,2).".".substr($datums,0,4); $kursi = $dati->Currencies; foreach ($kursi->Currency as $valuta) { $vID = $valuta->ID; $vUnits = $valuta->Units; $vRate = $valuta->Rate; } } Edited July 10, 2011 by aaxc Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.