コード例 #1
0
ファイル: API.php プロジェクト: JackPotte/xtools
 public function showArray($array)
 {
     if ($this->mFormat != 'xml') {
         $array = $this->removeElementKey('_element', $array);
     }
     switch ($this->mFormat) {
         case 'json':
             $prefix = $suffix = "";
             if (!is_null($this->mCallback)) {
                 $prefix = preg_replace("/[^][.\\'\\\"_A-Za-z0-9]/", "", $this->mCallback) . "(";
                 $suffix = ")";
             }
             $this->outputText($prefix . json_encode($array) . $suffix);
             break;
         case 'php':
             $this->outputText(serialize($array));
             break;
         case 'xml':
             $this->outputText('<?xml version="1.0"?>');
             $this->outputText(ArrayToXML::recXmlPrint('api', $array, $this->mIsHtml ? -2 : null));
             break;
         case 'yaml':
             require_once '/data/project/xtools/yaml.php';
             $this->outputText(Spyc::YAMLDump($array));
             break;
         case 'txt':
             $this->outputText(print_r($array, true));
             break;
         case 'dbg':
             $this->outputText(var_export($array, true));
             break;
     }
     if ($this->mIsHtml) {
         echo "\n</pre>";
     }
 }