我有这个PHP Code...
foreach($valoresa as $cada)
$listaDatos[$c++] = array('Date.UTC(' . date("Y", strtotime($cada['reading_date'])) . ',' . date("m", strtotime($cada['reading_date'])) . ',' . date("d", strtotime($cada['reading_date'])) . ',' . date("H", strtotime($cada['reading_date'])) . ',' . date("i", strtotime($cada['reading_date'])) . ',' . date("s", strtotime($cada['reading_date'])) . ')', floatval($cada['value']));
然后混合JS
和PHP
:
{
name: '<?php echo $nombreDato; ?>',
yAxis: <?php echo $yAxis++; ?>,
data: <?php echo json_encode($listaDatos); ?>
},
这是the result
:
data: [["Date.UTC(2013,06,26,16,03,35)",0],["Date.UTC(2013,06,26,16,04,35)",1],["Date.UTC(2013,06,26,16,06,35)",0]]
我要这个:(Without any quote)
data: [[Date.UTC(2013,06,26,16,03,35),0],[Date.UTC(2013,06,26,16,04,35),1],[Date.UTC(2013,06,26,16,06,35),0]]
我为什么要这样做?如果我做这样的事情:
foreach($valores01 as $cada)
$listaDatos[$c++] = array(strtotime($cada['reading_date']) * 1000, floatval($cada['value']));
正在识别数据日期,highcharts
比原始日期早 2 小时,我只想测试,Date.UTC()
因为原始示例是highcharts
这样的:http: //jsfiddle.net/JNkRR/
固定的:
我修复了@nnnnnn 提示,它非常简单,我在考虑任何 json php 函数或其他东西,但使用str_replace()
php 函数更简单:
<?php
$datosFinales = json_encode($listaDatos);
?>
{
name: '<?php echo $nombreDato; ?>',
yAxis: <?php echo $yAxis++; ?>,
data: <?php echo str_replace("\"", "", $datosFinales); ?>
},