public function translateArray(array $array)
    {
        $result = array();

        foreach ($array as $key => $value) {
            // Group translation
            if (is_array($value)) {
                $key = $this->translate($key);

                // If group is not created yet, create it
                if (!isset($result[$key])){
                    $result[$key] = array();
                }

                foreach($value as $index => $inner) {
                    $result[$key][$index] = $this->translate($inner);
                }
                
            } else if (is_scalar($value)) {
                $result[$key] = $this->translate($value);
            } else {
                throw new InvalidArgumentException('Invalid array supplied');
            }
        }

        return $result;
    }
public function translateArray(array $array)
    {
        $result = array();

        foreach ($array as $key => $value) {
            // Group translation
            if (is_array($value)) {
                $key = $this->translate($key);

                // If group is not created yet, create it
                if (!isset($result[$key])){
                    $result[$key] = array();
                }

                foreach($value as $index => $inner) {
                    $result[$key][$index] = $this->translate($inner);
                }
                
            } else if (is_scalar($value)) {
                $result[$key] = $this->translate($value);
            } else {
                throw new InvalidArgumentException('Invalid array supplied');
            }
        }

        return $result;
    }
public function translateArray ( array $ array ) { $ result = array ( ) ; foreach ( $ array as $ key => $ value ) { // Group translation if ( is_array ( $ value ) ) { $ key = $ this -> translate ( $ key ) ; // If group is not created yet, create it if ( ! isset ( $ result [ $ key ] ) ) { $ result [ $ key ] = array ( ) ; } foreach ( $ value as $ index => $ inner ) { $ result [ $ key ] [ $ index ] = $ this -> translate ( $ inner ) ; } } else if ( is_scalar ( $ value ) ) { $ result [ $ key ] = $ this -> translate ( $ value ) ; } else { throw new InvalidArgumentException ( 'Invalid array supplied' ) ; } } return $ result ; }
Translate array values if possible

@param array $array
@throws \InvalidArgumentException if at least one array's value isn't a string
@return array
Translate array values if possible