|
Server : Apache/2.2.2 (Fedora) System : Linux App1.pathumtani.go.th 2.6.20-1.2320.fc5smp #1 SMP Tue Jun 12 19:40:16 EDT 2007 i686 User : apache ( 48) PHP Version : 5.2.9 Disable Function : NONE Directory : /var/www/html/networkmonitor/ajaxMyTop/lib/ |
Upload File : |
<?php
class ProcessList{
// using public properties for simplicity
public $threads = array();
// function to dump properties in JSON format as a JS variable called 'explain'
function getJSON(){
$json = "var processList = { ";
$json .= "threads: [ ";
if (count($this->threads) > 0){
foreach ($this->threads as $thread){
$json .= "{ ";
foreach(array_keys($thread) as $threadField){
$json .= " $threadField : \"" . $thread[$threadField] . "\", ";
}
// after final field, chop off the ', ' and add '}, ' to prepare for next row
$json = substr($json, 0, strlen($json)-2) . "}, ";
}
// after the final row, chop off the ', ' and add ']' to finish array
$json = substr($json, 0, strlen($json)-2);
}
$json .= "]";
if ($this->error) $json .= ", error: \"" . $this->error . "\"";
$json .= "};";
echo $json;
}
}
?>