我有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
的原始示例是这样做的:{{3 }}
FIXED:
我修复了@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); ?>
},
答案 0 :(得分:0)
我用@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); ?>
},