I tried in many ways, but none is my specific problem, I tried to use what I know, but to no avail. I'm trying to use file_get_contents to get the json from 1 file.json on my server, and calculate a specific array, but after the "array_column" it returns an empty array.
<?php
$json_url = "http://myserver/file.json";
$json = file_get_contents($json_url);
$data = json_decode($json, true);
$price = array_column($data, 'valor');
print_r($price);
//output = array() | empyty array
the $json return the correct json, in the $data return the corret decoded json, but in $price, return empty array()
the $json content of my json file in my server is similar to it:
{
"1228421731": [
{
"valor": 10,
"datelimite": 1644024834,
"date": 1643420034,
"codigo": "ALYCGKU76S"
}
],
"1111925985": [
{
"valor": 25,
"datelimite": 1644066350,
"date": 1643461550,
"codigo": "HK8NQROGBW"
}
],
"1413051871": [
{
"valor": 50,
"datelimite": 1644084293,
"date": 1643479493,
"codigo": "4NGJ523J6H"
}
],
"1209626299": [
{
"valor": 10,
"datelimite": 1644091732,
"date": 1643486932,
"codigo": "W7LRGY3FHZ"
}
],
"1803561706": [
{
"valor": 10,
"datelimite": 1644257719,
"date": 1643652919,
"codigo": "GE8IDPZN9H"
},
{
"valor": 19865091226,
"datelimite": 1644288984,
"date": 1643684184,
"codigo": "F5Q9TPE43SWAFX"
}
],
"1710879952": [
{
"valor": 19865091226,
"datelimite": 1644274668,
"date": 1643669868,
"codigo": "P5M4E6RP1ZPEUR"
}
],
"1907375762": [
{
"valor": 10,
"datelimite": 1644377257,
"date": 1643772457,
"codigo": "E8OKPVCYVWRHUI"
}
],
"1863764959": [
{
"valor": 25,
"datelimite": 1644427955,
"date": 1643823155,
"codigo": "L78EZKJZJ93UYW"
}
],
"1831713303": [
{
"valor": 10,
"datelimite": 1644442109,
"date": 1643837309,
"codigo": "3J84VTS5FRS6OI"
}
],
"5193759120": [
{
"valor": 10,
"datelimite": 1644453308,
"date": 1643848508,
"codigo": "88942HFHZ5JJ56"
}
],
"1785872541": [
{
"valor": 10,
"datelimite": 1644504518,
"date": 1643899718,
"codigo": "LBML4O31RLC7DW"
}
],
"1666986497": [
{
"valor": 1,
"datelimite": 1644667829,
"date": 1644063029,
"codigo": "HXHPK6XLNBD89E"
}
]
}
how can i use array_column for this json type? for the array 'valor'?