示例#1
0
        } elseif (is_int($val)) {
            return sprintf('%d', $val);
        } elseif (is_float($val)) {
            return sprintf('%F', $val);
        } elseif (is_bool($val)) {
            return $val ? 'true' : 'false';
        } else {
            return 'null';
        }
    }
}
// prints ["apple","banana","blueberry"]
echo custom_json::encode(array('apple', 'banana', 'blueberry'));
// prints {"name":"orange","type":"fruit"}
echo custom_json::encode(array('name' => 'orange', 'type' => 'fruit'));
// prints: ** try it yourself, cannot post long lines here **
$big_test = array(array('name' => array('John', 'Smith'), 'age' => 27, 'sex' => 0, 'height' => 180.53, 'is_human' => true, 'string' => 'Hello'), array('name' => array('Green', 'Alien'), 'age' => 642, 'sex' => null, 'height' => 92.20999999999999, 'is_human' => false, 'string' => '?????!'));
echo custom_json::encode($big_test);
/*
JAVASCRIPT FUNCTION - decode rawurlencoded() strings
==================
function decodeData(data) {
        for(var item in data) {
            var type = typeof data[item];
            if(type === 'object') decodeData(data[item]);
            else if(type === 'string') data[item] = decodeURIComponent(data[item]);
        }
    }
*/
?>
?>
示例#2
0
	public function getPage(){

		if ($this->getParam('ajax')) {
			for ($i = 0 ; $i < 10 ; $i++) ob_end_clean();
			header('Content-type: text/html; charset=windows-1251');

			switch ($this->getParam('ajax')){
				case 'calculate':
					$this->ajax_calculate( $this->getParam('vklad') );
					break;
			}

			exit;
		}


		$DATA = array(
			'action'=>$this->action,
			'VKLAD_json' => custom_json::encode( $this->getVklady() ),
			'SR' => $this->getRefinansirovanie(),
		);


		//  подготавливаем данные о вкладах
		$VAL = $this->getValutsList();
		$Vklady = array();
		foreach ($VAL as $val_key=>$val_name){
			if($VKL = $this->getVklady( array('vklad_val' => $val_key) ) ){
				$Vklady[$val_key] = $VKL;
				$DATA['VAL'][$val_key] = $val_name;
			}
		}



		TPL::PrnTpl('obligacii_standart',$DATA);
		//F::debug($DATA);
	}