diff options
author | dchill42 <dchill42@gmail.com> | 2012-07-31 15:41:01 +0200 |
---|---|---|
committer | dchill42 <dchill42@gmail.com> | 2012-07-31 15:41:01 +0200 |
commit | 7e92b7332ea4d28648e69eabcb93cead35dbca26 (patch) | |
tree | b7714536b89557129ed51fe675725fe28639c1e0 /system/core/Common.php | |
parent | 57486009573a86d9e286a49c92216ba17aae0d5a (diff) | |
parent | 3a2d573a96241c01124d15c1ce517078e07c6235 (diff) |
Merge branch 'develop' of github.com:/EllisLab/CodeIgniter into session
Diffstat (limited to 'system/core/Common.php')
-rw-r--r-- | system/core/Common.php | 39 |
1 files changed, 39 insertions, 0 deletions
diff --git a/system/core/Common.php b/system/core/Common.php index 06b162264..57374b07d 100644 --- a/system/core/Common.php +++ b/system/core/Common.php @@ -598,5 +598,44 @@ if ( ! function_exists('html_escape')) } } +// ------------------------------------------------------------------------ + +if ( ! function_exists('_stringify_attributes')) +{ + /** + * Stringify attributes for use in HTML tags. + * + * Helper function used to convert a string, array, or object + * of attributes to a string. + * + * @param mixed string, array, object + * @param bool + * @return string + */ + function _stringify_attributes($attributes, $js = FALSE) + { + $atts = NULL; + + if (empty($attributes)) + { + return $atts; + } + + if (is_string($attributes)) + { + return ' '.$attributes; + } + + $attributes = (array) $attributes; + + foreach ($attributes as $key => $val) + { + $atts .= ($js) ? $key.'='.$val.',' : ' '.$key.'="'.$val.'"'; + } + + return rtrim($atts, ','); + } +} + /* End of file Common.php */ /* Location: ./system/core/Common.php */
\ No newline at end of file |