|  |  |  | 
|---|
|  |  |  | // Ignore  < ? php  and  ? >  added above | 
|---|
|  |  |  | if($token[0] == T_OPEN_TAG OR $token[0] == T_CLOSE_TAG) continue; | 
|---|
|  |  |  | // String/int element within an array | 
|---|
|  |  |  | if($token[0] == T_CONSTANT_ENCAPSED_STRING || $token[0] == T_LNUMBER) { | 
|---|
|  |  |  | if($token[0] == T_CONSTANT_ENCAPSED_STRING) { | 
|---|
|  |  |  | $element = substr($token[1], 1, -1); | 
|---|
|  |  |  | } | 
|---|
|  |  |  | if($token[0] == T_LNUMBER) { | 
|---|
|  |  |  | $element = $token[1]; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // Nested array | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // End of nested array | 
|---|
|  |  |  | elseif($token == ']') { | 
|---|
|  |  |  | // Put elements into the lastest array | 
|---|
|  |  |  | // Put elements into the latest array | 
|---|
|  |  |  | if($element !== NULL && $element !== FALSE) { | 
|---|
|  |  |  | end($stack); | 
|---|
|  |  |  | $stack[key($stack)][] = $element; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | // Elements separator | 
|---|
|  |  |  | elseif($token == ',') { | 
|---|
|  |  |  | // Put elements into the lastest array (]] check) | 
|---|
|  |  |  | // Put elements into the latest array (]] check) | 
|---|
|  |  |  | if($element !== FALSE) { | 
|---|
|  |  |  | end($stack); | 
|---|
|  |  |  | $stack[key($stack)][] = $element; | 
|---|
|  |  |  | 
|---|
|  |  |  | } | 
|---|
|  |  |  | else | 
|---|
|  |  |  | { | 
|---|
|  |  |  | return array(); | 
|---|
|  |  |  | return FALSE; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  |  | 
|---|
|  |  |  | return $stack[0][0]; | 
|---|
|  |  |  | if(isset($stack[0][0])) { | 
|---|
|  |  |  | return $stack[0][0]; | 
|---|
|  |  |  | } else { | 
|---|
|  |  |  | return NULL; | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | } | 
|---|
|  |  |  | ?> | 
|---|