duan0714 2014-04-10 22:19
浏览 25
已采纳

PHP var的Highcharts

I am novice with JavaScript, and in my website I need to use highchart with some PHP var. And I have a question : With Highchart, I need to complete some information :

xAxis: {
    categories: ['Jan', 'Feb', 'Mar', 'Apr', 'May', 'Jun', 'Jul', 'Aug', 'Sep', 'Oct', 'Nov', 'Dec']
},

I have my array in PHP coverted in JavaScript with :

var array = <?php echo json_encode($array); ?>;

But, the length of my array is never the same length between differents users. And I need to complete "categories" with all the values in my array.

How can I do this?

  • 写回答

2条回答 默认 最新

  • dougong5817 2014-04-11 20:05
    关注

    My actual code is the following :

    xAxis: {
        categories: [<?php foreach($array as $value) {
            echo "'".$value."', ";
        }?>]
    },
    

    But it doesn't work, because the graph don't appear. :/

    EDIT : Solution is :

    var array = <?php echo json_encode($array); ?>;
    

    And then

    xAxis: {
        categories: array 
    },
    
    本回答被题主选为最佳回答 , 对您是否有帮助呢?
    评论
查看更多回答(1条)

报告相同问题?

悬赏问题

  • ¥15 vika文档如何与obsidian同步
  • ¥15 华为手机相册里面的照片能够替换成自己想要的照片吗?
  • ¥15 陆空双模式无人机飞控设置
  • ¥15 sentaurus lithography
  • ¥100 求抖音ck号 或者提ck教程
  • ¥15 关于#linux#的问题:子进程1等待子进程A、B退出后退出(语言-c语言)
  • ¥20 web页面如何打开Outlook 365的全球离线通讯簿功能
  • ¥15 io.jsonwebtoken.security.Keys
  • ¥15 急,ubuntu安装后no caching mode page found等
  • ¥15 联想交换机NE2580O/NE1064TO安装SONIC