Skip to main content
Stack Overflow
  1. About
  2. For Teams

Return to Question

Post Timeline

I have a json array in php and I want to pass it to javascript so I can use it with google charts.

If I do this: var a = ;

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

I get the data in the format Name,Value,PHP,78,JAVA,1000,HTML,129Name,Value,PHP,78,JAVA,1000,HTML,129 but I want to keep it in the jsonjson format that it was in [["Name","Value"],["PHP",78],["JAVA",1000],["HTML",129]]​

[["Name","Value"],["PHP",78],["JAVA",1000],["HTML",129]]​

because google charts needs to receive it like this. Any idea how to do this?

I have a json array in php and I want to pass it to javascript so I can use it with google charts.

If I do this: var a = ; I get the data in the format Name,Value,PHP,78,JAVA,1000,HTML,129 but I want to keep it in the json format that it was in [["Name","Value"],["PHP",78],["JAVA",1000],["HTML",129]]​ because google charts needs to receive it like this. Any idea how to do this?

I have a json array in php and I want to pass it to javascript so I can use it with google charts.

If I do this:

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

I get the data in the format Name,Value,PHP,78,JAVA,1000,HTML,129 but I want to keep it in the json format that it was in

[["Name","Value"],["PHP",78],["JAVA",1000],["HTML",129]]​

because google charts needs to receive it like this. Any idea how to do this?

Source Link
Vickie
  • 99
  • 1
  • 9

Pass json object from php to javascript

I have a json array in php and I want to pass it to javascript so I can use it with google charts.

If I do this: var a = ; I get the data in the format Name,Value,PHP,78,JAVA,1000,HTML,129 but I want to keep it in the json format that it was in [["Name","Value"],["PHP",78],["JAVA",1000],["HTML",129]]​ because google charts needs to receive it like this. Any idea how to do this?

default

AltStyle によって変換されたページ (->オリジナル) /