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 微信公众平台自制会员卡可以通过收款码收款码收款进行自动积分吗
  • ¥15 随身WiFi网络灯亮但是没有网络,如何解决?
  • ¥15 gdf格式的脑电数据如何处理matlab
  • ¥20 重新写的代码替换了之后运行hbuliderx就这样了
  • ¥100 监控抖音用户作品更新可以微信公众号提醒
  • ¥15 UE5 如何可以不渲染HDRIBackdrop背景
  • ¥70 2048小游戏毕设项目
  • ¥20 mysql架构,按照姓名分表
  • ¥15 MATLAB实现区间[a,b]上的Gauss-Legendre积分
  • ¥15 delphi webbrowser组件网页下拉菜单自动选择问题