0👍
As stated in the docs for print_r(): “Prints human-readable information about a variable”. Human-readable information is rarely useful to a computer.
Instead, you want the data in a format that can easily be parsed by your program. In the case of chart.js, that format would be JSON. You’re already JSON-encoding the data, you just need to stop wrapping it in the extra formatting that comes along with print_r()
. Instead, simply just output the data with echo
.
var WData = <?php echo json_encode($WData);?>;
- Chartjs-How to reorganize data to display how many times a string appears in an array object?
- Chartjs-Chart.js How can i make a horizontal lines like this?
Source:stackexchange.com