Ok I am getting info from poloniex API.
It comes back as an array like so:
Array ( [0] => Array ( [id] => 357988064 [currency] => DOGE [rate] => 0.00008000 [amount] => 3134.03982846 [duration] => 0.25540000 [interest] => 0.06403308 [fee] => -0.00960496 [earned] => 0.05442812 [open] => 2017-05-30 23:12:09 [close] => 2017-05-31 05:19:55 ) [1] => Array ... and so on
Now I am trying to get each element of the array into some sort of variable to use later.
So something like this:
$id=[id]
$currency=[currency]
$rate=[rate]
$amount=[amount]
$duration=[duration]
$interest=interest]
$fee=fee]
$earned=[earned]
$open=[open]
$close=[close]
I want to put them into a mysqli DB
This is what i am using right now:
if (!$return) {
echo "No Data";
print_r($return);
} else {
$arrlength=count($return);
echo "this many results: " .$arrlength. "<br><br>";
foreach($return as $x=>$x_value)
{
echo $return[0][0]. ": Currency: " .$return[0][1]. ". Rate: " .$return[0][2]. " Duration: " .$return[0][3]. " Interest: " .$return[0][4]. " Fee: " .$return[0][5]. " Earned: " .$return[0][6]. " Opened: " .$return[0][7]. " Closed: " .$return[0][8]. "<br>";
// insert into Database here
}
// print_r($return);
}
And all it is returning is
: Currency: . Rate: Duration: Interest: Fee: Earned: Opened: Closed:
I am a newbie with arrays but i have had success with api's with Json this is 1st with Arrays.
Been tinkering for a few days with this and i just cant get the right combo
EDIT: for anyone who can use this info i went the answer below and to display it on one line i went like this.
if (!$return) {
echo "No Data";
//print_r($return);
} else {
$arrlength=count($return);
echo "this many results: " .$arrlength. "<br><br>";
foreach($return as $x=>$x_value){
extract($x_value);
echo $id." " .$currency." " .$rate." " .$duration." " .$interest." " .$fee." " .$earned." " .strtotime($open)." " .strtotime($close)."<br>";
// insert into Database here
}
// print_r($return);
}