$_REQUEST['local_graph_id'], 'rra_id' => $_REQUEST['rra_id']); // Determine the graph type of the output $type = db_fetch_cell('SELECT image_format_id FROM graph_templates_graph WHERE local_graph_id=' . $_REQUEST['local_graph_id']); switch($type) { case '1': $oarray['type'] = 'png'; break; case '3': $oarray['type'] = 'svg+xml'; break; } $lpos = 0; while (true) { $pos = strpos($output, "\n", $lpos); if ($pos > 0) { //echo ">>>>" . substr($output,$lpos,$pos-$lpos) . "<<<<\n"; $parts = explode('=', substr($output,$lpos,$pos-$lpos)); $name = trim($parts[0]); $value = trim($parts[1]); if ($name == 'image') { $oarray[$name] = base64_encode(substr($output,$pos+1)); break; }else{ $oarray[$name] = $value; } $lpos = $pos + 1; } } print json_encode($oarray);