code/control/KapostService.php
final protected function struct_to_assoc($struct) {
        $result=array();
        foreach($struct as $item) {
            if(array_key_exists('key', $item) && array_key_exists('value', $item)) {
                if(array_key_exists($item['key'], $result)) {
                    user_error('Duplicate key detected in struct entry, content overwritten by the last entry: [New: '.print_r($item, true).'] [Previous: '.print_r($result[$item['key']], true).']', E_USER_WARNING);
                }
                
                $result[$item['key']]=$item['value'];
            }else {
                user_error('Key/Value pair not detected in struct entry: '.print_r($item, true), E_USER_NOTICE);
            }
        }
        
        return $result;
    }
final protected function struct_to_assoc($struct) {
        $result=array();
        foreach($struct as $item) {
            if(array_key_exists('key', $item) && array_key_exists('value', $item)) {
                if(array_key_exists($item['key'], $result)) {
                    user_error('Duplicate key detected in struct entry, content overwritten by the last entry: [New: '.print_r($item, true).'] [Previous: '.print_r($result[$item['key']], true).']', E_USER_WARNING);
                }
                
                $result[$item['key']]=$item['value'];
            }else {
                user_error('Key/Value pair not detected in struct entry: '.print_r($item, true), E_USER_NOTICE);
            }
        }
        
        return $result;
    }
final protected function struct_to_assoc ( $ struct ) { $ result = array ( ) ; foreach ( $ struct as $ item ) { if ( array_key_exists ( 'key' , $ item ) && array_key_exists ( 'value' , $ item ) ) { if ( array_key_exists ( $ item [ 'key' ] , $ result ) ) { user_error ( 'Duplicate key detected in struct entry, content overwritten by the last entry: [New: ' . print_r ( $ item , true ) . '] [Previous: ' . print_r ( $ result [ $ item [ 'key' ] ] , true ) . ']' , E_USER_WARNING ) ; } $ result [ $ item [ 'key' ] ] = $ item [ 'value' ] ; } else { user_error ( 'Key/Value pair not detected in struct entry: ' . print_r ( $ item , true ) , E_USER_NOTICE ) ; } } return $ result ; }
Converts a struct to an associtive array based on the key value pair in the struct
@param array $struct Input struct to be converted
@return array Associtive array matching the struct
Converts a struct to an associtive array based on the key value pair in the struct