src/WebService.php
public function getResponseByKey( $needle = false, $offset = 0, $length = null ){

        // set respons to json
        $this->setEndpoint('json');

        // set default key parameter
        $needle = empty( $needle )
                    ? metaphone($this->service['responseDefaultKey'])
                    : metaphone($needle);

        // get response
        $obj = json_decode( $this->get(), true);

        // flatten array into single level array using 'dot' notation
        $obj_dot = array_dot($obj);
        // create empty response
        $response = [];
        // iterate 
        foreach( $obj_dot as $key => $val){

            // Calculate the metaphone key and compare with needle
            if( strcmp( metaphone($key, strlen($needle)), $needle) === 0 ){
                // set response value
                array_set($response, $key, $val);
            }
        }

        // finally extract slice of the array
        #return array_slice($response, $offset, $length);

        return count($response) < 1
               ? $obj
               : $response;


    }
public function getResponseByKey( $needle = false, $offset = 0, $length = null ){

        // set respons to json
        $this->setEndpoint('json');

        // set default key parameter
        $needle = empty( $needle )
                    ? metaphone($this->service['responseDefaultKey'])
                    : metaphone($needle);

        // get response
        $obj = json_decode( $this->get(), true);

        // flatten array into single level array using 'dot' notation
        $obj_dot = array_dot($obj);
        // create empty response
        $response = [];
        // iterate 
        foreach( $obj_dot as $key => $val){

            // Calculate the metaphone key and compare with needle
            if( strcmp( metaphone($key, strlen($needle)), $needle) === 0 ){
                // set response value
                array_set($response, $key, $val);
            }
        }

        // finally extract slice of the array
        #return array_slice($response, $offset, $length);

        return count($response) < 1
               ? $obj
               : $response;


    }
public function getResponseByKey ( $ needle = false , $ offset = 0 , $ length = null ) { // set respons to json $ this -> setEndpoint ( 'json' ) ; // set default key parameter $ needle = empty ( $ needle ) ? metaphone ( $ this -> service [ 'responseDefaultKey' ] ) : metaphone ( $ needle ) ; // get response $ obj = json_decode ( $ this -> get ( ) , true ) ; // flatten array into single level array using 'dot' notation $ obj_dot = array_dot ( $ obj ) ; // create empty response $ response = [ ] ; // iterate  foreach ( $ obj_dot as $ key => $ val ) { // Calculate the metaphone key and compare with needle if ( strcmp ( metaphone ( $ key , strlen ( $ needle ) ) , $ needle ) === 0 ) { // set response value array_set ( $ response , $ key , $ val ) ; } } // finally extract slice of the array #return array_slice($response, $offset, $length); return count ( $ response ) < 1 ? $ obj : $ response ; }
Get response value by key
@param string $needle - retrieves response parameter using "dot" notation
@param int $offset
@param int $length
@return array
Get response value by key