Not a member of Pastebin yet?
Sign Up,
it unlocks many cool features!
- <?php
- set_error_handler('exceptions_error_handler');
- register_shutdown_function( "fatal_handler" );
- // ------------
- $response = '
- {
- "data": [
- {
- "0": "0.0",
- "1": 1,
- "2": "0.2",
- "3": "0.3"
- },
- {
- "0": "1.0",
- "1": "1.1",
- "2": "1.2",
- "3": 3,
- "4": "1.4",
- "5": "1.5",
- "6": "1.6",
- "7": "1.7"
- }
- ]
- }
- ';
- // $data = null;
- function g($data, $i) {
- try {
- return $data[$i];
- }catch(Exception $e){
- return false;
- }
- }
- function main($response, $data = false) {
- try { $data = json_decode($response,false)->{'data'}; } catch(Exception $e) { }
- if (!$data) return;
- // var_dump($data);
- function obj($obj){
- $i = 0;
- while(true){
- $data = NULL;
- try {
- $data = $obj->{$i};
- } catch(Exception $e){}
- if($data === NULL) break;
- if("object" === gettype($data))obj($data);
- if("array" === gettype($data))arr($data);
- if("string" === gettype($data))print "str $i $datan";
- if("integer" === gettype($data))print "int $i $datan";
- $i++;
- }
- return true;
- }
- function arr($arr){
- $i = 0;
- while(true){
- $data = NULL;
- try {
- $data = $arr[$i];
- } catch(Exception $e){}
- if($data === NULL) break;
- if("object" === gettype($data))obj($data);
- if("array" === gettype($data))arr($data);
- $i++;
- }
- return true;
- }
- // if("object" === gettype($data))
- // if("array" === gettype($data))
- arr($data);
- }
- main($response);
- echo "nendn";
- // -------------------
- function exceptions_error_handler($severity, $message, $filename, $lineno) {}
- function fatal_handler() {}
- ?>
Add Comment
Please, Sign In to add comment