I have this php code, i need to know is it possible $data
objects put as array, I wanna return result as:
Array ( [0] => stdClass Object ( [rate] => 1 [currencyCode] => USD ) [1] => stdClass Object ( [rate] => 2 [currencyCode] => CAD ) [2] => stdClass Object ( [rate] => 3 [currencyCode] => AUD )...)
Now im getting iy without Array.
<?php
class testing_model extends CI_Model{
function displayCurrency(){
$array = array();
$data = new stdClass();
$i=0;
$XMLContent=file("http://www.ecb.europa.eu/stats/eurofxref/eurofxref-daily.xml");
foreach($XMLContent as $line){
if(preg_match("/currency='([[:alpha:]]+)'/",$line,$currencyCode)){
if(preg_match("/rate='([[:graph:]]+)'/",$line,$rate)){
//Output the value of 1EUR for a currency code
$data->rate = $rate[1];
$data->currencyCode = $currencyCode[1];
print_r($data);
}
}
}
}
}