I have a multi dimensional array that consists of 3 arrays inside. See below my minimum runnable example:
<?php
$array1 = array("Bitcoin", "Ethereum", "Bitcoin Cash");
$array2 = array("BTC", "ETH", "BTC");
$array3 = array("10000", "3000", "6666");
//Multi Dimensional Array
$multi = array($array1, $array2, $array3);
print_r($multi);
foreach($multi as $k =>$a){
$multi[$k] = json_decode(json_encode($a));
}
print_r($multi);
// $json_data = json_encode($multi);
file_put_contents('data/myfile.json', $multi);
However, I get the following output in my output file:
ArrayArrayArray
Any suggestions how to get the data like the following:
{
"Bitcoin",
"BTC",
"10000"
},
{
"Ethereum",
"ETH",
"3000"
},
{
"Bitcoin Cash",
"BTC",
"6666"
},
{}are for objects{ key: 'value', key2: 'value2', ... }while[]is for arrays['item1', 'item2', ...]