3v4l.org

run code in 200+ PHP versions simultaneously
<?php $js = ''; $resultset = [ ["title" => "Cash", "value" => 40, "color" => "#2C3E50"], ["title" => "Fixed Interest", "value" => 8, "color" => "#FE4400"], ["title" => "Property", "value" => 24, "color" => "#018AB6"], ["title" => "Australian shares", "value" => 16, "color" => "#FFF100"], ["title" => "Intl. shares", "value" => 12, "color" => "#D7DADB"] ]; $json = json_encode($resultset); $piechart_id = "piechart1"; // this seems sensible if inside of a loop $js .= "$('#{$piechart_id}').drawPieChart({$json})"; echo $js;
based on v6Q4u
Output for 7.1.0 - 7.4.0
$('#piechart1').drawPieChart([{"title":"Cash","value":40,"color":"#2C3E50"},{"title":"Fixed Interest","value":8,"color":"#FE4400"},{"title":"Property","value":24,"color":"#018AB6"},{"title":"Australian shares","value":16,"color":"#FFF100"},{"title":"Intl. shares","value":12,"color":"#D7DADB"}])