array(10) {
["table_name"]=>
string(0) ""
["chart_type"]=>
string(5) "Table"
["chart_name"]=>
string(9) "Veterans "
["dashboard_name"]=>
string(7) "Default"
["data_option"]=>
string(0) ""
["limit_value"]=>
string(1) "0"
["view_status"]=>
bool(true)
["view_priority"]=>
string(0) ""
["chart_data"]=>
array(72) {
[0]=>
array(11) {
[0]=>
string(4) "Rank"
[1]=>
string(6) "Branch"
[2]=>
string(12) "Level 3 Name"
[3]=>
string(12) "Level 4 Name"
[4]=>
string(23) "Logged Premia Score MTD"
[5]=>
string(26) "Converted Premia Score MTD"
[6]=>
string(21) "Persistancy Score MTD"
[7]=>
string(23) "Logged Premia Score YTD"
[8]=>
string(26) "Converted Premia Score YTD"
[9]=>
string(21) "Persistancy Score YTD"
[10]=>
string(5) "Score"
}
[1]=>
array(11) {
[0]=>
float(1)
[1]=>
string(22) " GWALIOR DIRECTSegment"
[2]=>
string(29) "G00563 - GOVIND SINGH KUSHWAH"
[3]=>
string(21) "S03643 - Shishir Jain"
[4]=>
float(1)
[5]=>
float(1)
[6]=>
float(1)
[7]=>
float(0.9994)
[8]=>
float(1)
[9]=>
float(1)
[10]=>
float(9.89901)
}
[2]=>
array(11) {
[0]=>
float(2)
[1]=>
string(26) " KURUKSHETRA DIRECTSegment"
[2]=>
string(23) "A02311 - Amarjeet Singh"
[3]=>
string(21) "S00927 - Sachin Kumar"
[4]=>
float(1)
[5]=>
float(1)
[6]=>
float(1)
[7]=>
float(0.953)
[8]=>
float(1)
[9]=>
float(1)
[10]=>
float(9.82245)
}
}
["color_scheme_name"]=>
string(7) "Default"
}
如何在php中显示chart_data
$arr=json_decode($row[0],TRUE);
var_dump($arr);
foreach($arr as $row)
{
foreach($row['chart_data'] as $k)
{
echo $k['Rank'];
echo $k['Branch'];
}
}
编辑:for ($x=0; $x<=count
($arr['chart_data']); $x++) {
foreach($arr['chart_data'][$x] as $key=>$val)
{
echo $val;
}
}
您每个呼叫有2个。
第一个传递外部数组的所有键,其中chart_data
。
第二个查看外部数组的子数组,并在每个子数组中查找chart_data
。但显然没有找到任何。
把你的代码改成:
$arr=json_decode($row[0],TRUE);
foreach($arr['chart_data'] as $k){
echo $k['Rank'];
echo $k['Branch'];
}
编辑:我明白了。(感谢缩进你的数组)你的问题当然是$arr['rank']
和$arr['branch']
不存在。它们只是$k[0]
和$k[1]
中的字符串,它们本身不包含任何其他数据。
您希望看到输出什么?
也许这就是解决办法。
$arr = json_decode($row[0],TRUE);
foreach($row['chart_data'] as $chart_data)
{
foreach($chart_data[0] as $k)
{
echo $k['Rank'];
echo $k['Branch'];
}
}
:
, 分支是价值观。你的数组格式错误。
$arr = json_decode($row[0],TRUE);
foreach($row['chart_data'] as $chart_data)
{
foreach($chart_data[0] as $k)
{
echo $k[0];
echo $k[1];
}
}