我試圖創建一個圖表基於一些PHP數據我在數組中了,如果我運行下面的PHP數組JSON格式
<?php
$out = array_values($periodi);
echo json_encode($out, JSON_PRETTY_PRINT);
?>
我得到這個JSON格式
[
"Francia",
"Italia",
"Italia",
"Germania",
"Afghanistan",
"Italia"
]
雖然我正在尋找的是獲得這樣的格式。無論不同的價值,我如何在漫遊器中添加一個合適的名稱來獲取這些行中的內容?
var data = [{
"name": "Tokyo",
"data": 3.0
}, {
"name": "NewYork",
"data": 2.0
}, {
"name": "Berlin",
"data": 3.5
}, {
"name": "London",
"data": 1.5
}];
print_r($ periodi);
陣列([0] =>莫德爾諾[1] =>的Contemporâneo[2] =>的Contemporâneo[3] =>的Contemporâneo[4] =>的Contemporâneo)
我有另一個數組用不同的數據,但仍格式是錯誤的:
陣列([弗蘭切塞] =>數組([MASCHIO] =>數組([0] => 1) [femmina] =>數組([0] => 1))[chimica] => Array([maschio] => Array([0] => 1 [1] => 1))[fisica] => Array([ma數組([數組] =>陣列([數組])>數組([數組]([數組])[數組([數組]數組([0] => 1))[數組] =>數組([0] =>數組([0] => > 1))[意大利語] =>數組([femmina] =>數組([0] => 1)))
{
"maschio": [
true
],
"femmina": [
true
]
},
{
"maschio": [
true,
true
]
},
{
"maschio": [
true,
true
],
"femmina": [
true
]
},
{
"maschio": [
true
]
},
{
"maschio": [
true
]
},
{
"maschio": [
true
]
},
{
"femmina": [
true
]
}
]
更新您的文章用'的print_r($ periodi)' –
@SahilGulati更新,它在這個問題 –
這是一個樣本陣列或實際呢?你的問題是不完整的 –