s and \n"; } private static function add_label($input, $desc, $desc_pos) { if ( empty($desc_pos) ) $desc_pos = 'after'; $label = ''; if ( false === strpos($desc, self::token) ) { switch ($desc_pos) { case 'before': $label = $desc . ' ' . self::token; break; case 'after': $label = self::token . ' ' . $desc; } } else { $label = $desc; } $label = trim(str_replace(self::token, $input, $label)); if ( empty($desc) ) $output = $input . "\n"; else $output = "\n"; return $output; } private static function validate_extra($extra, $name, $implode = true) { if ( !is_array($extra) ) $extra = explode(' ', $extra); if ( empty($extra) ) return ''; return ' ' . ltrim(implode(' ', $extra)); } // Utilities private static function is_associative($array) { if ( !is_array($array) || empty($array) ) return false; $keys = array_keys($array); return array_keys($keys) !== $keys; } private static function array_extract($array, $keys) { $r = array(); foreach ( $keys as $key ) if ( isset($array[$key]) ) $r[$key] = $array[$key]; return $r; } } // PHP < 5.2 if ( !function_exists('array_fill_keys') ) : function array_fill_keys($keys, $value) { if ( !is_array($keys) ) trigger_error('First argument is expected to be an array.' . gettype($keys) . 'given', E_USER_WARNING); $r = array(); foreach ( $keys as $key ) $r[$key] = $value; return $r; } endif;