Re: PHP array for use in javascript

2009-06-01 Thread icc97
Hi Céryl, This was very useful for me as I'm trying to use flot as well. I did something similar by first trying to build up an array of tuples and then used the $javascript->object() function which produces a JSON array which is perfect input for flot e.g. foreach($data as $key => $val){ $

Re: PHP array for use in javascript

2009-05-18 Thread Céryl
Worked almost a charm... Still, I ended up writing a this codeblock to manually make-up the output the way I want it: $i=0; $output = "["; foreach($data as $key=>$val){ if ($i != 0) {$output .= ", ";} $output .= "[".$key.", ".$val."]"; $i++; } $output .= "]"; echo $output

Re: PHP array for use in javascript

2009-05-18 Thread brian
You could use the JavascriptHelper to create the array, or any other block of JS code. On Mon, May 18, 2009 at 12:10 PM, Céryl wrote: > > Hej all! > > I've been trying to find a solution for this, and maybe I'm > approaching it wrong. This is the case: > > For my site I need make graphs out of d

Re: PHP array for use in javascript

2009-05-18 Thread Martin Westin
Hi, Try looking at JavascriptHelper::object() http://api.cakephp.org/class/javascript-helper#method-JavascriptHelperobject It will help you render a javascript object of any data you have in php. ...or just parse out your data to a string yourself and set it as a javascript variable. (= use php

PHP array for use in javascript

2009-05-18 Thread Céryl
Hej all! I've been trying to find a solution for this, and maybe I'm approaching it wrong. This is the case: For my site I need make graphs out of data in a table. I have picked JQuery FLOT for making the graphs. However, FLOT needs data in a jQuery array build like: [[xaxis, yaxis] [xaxis, yax