\<\-]/i", "", remove_accents ((string)$string)); } /** * Trims deeply. * * @package s2Member\Utilities * @since 3.5 * * @param str|array $value Either a string, an array, or a multi-dimensional array, filled with integer and/or string values. * @return str|array Either the input string, or the input array; after all data is trimmed up. */ public static function trim_deep ($value = FALSE) { return is_array ($value) ? array_map ("c_ws_plugin__s2member_utils_strings::trim_deep", $value) : trim ((string)$value); } /** * Trims " entities deeply. * * This is useful on Shortcode attributes mangled by a Visual Editor. * * @package s2Member\Utilities * @since 3.5 * * @param str|array $value Either a string, an array, or a multi-dimensional array, filled with integer and/or string values. * @return str|array Either the input string, or the input array; after all data is trimmed up. */ public static function trim_quot_deep ($value = FALSE) { return is_array ($value) ? array_map ("c_ws_plugin__s2member_utils_strings::trim_quot_deep", $value) : preg_replace ("(^(")+|(")+$)", "", (string)$value); } /** * Trims double quotes deeply. * * This is useful on CSV data that is encapsulated by double quotes. * * @package s2Member\Utilities * @since 3.5 * * @param str|array $value Either a string, an array, or a multi-dimensional array, filled with integer and/or string values. * @return str|array Either the input string, or the input array; after all data is trimmed up. */ public static function trim_dq_deep ($value = FALSE) { return is_array ($value) ? array_map ("c_ws_plugin__s2member_utils_strings::trim_dq_deep", $value) : trim ((string)$value, "\" \t\n\r\0\x0B"); } /** * Wraps a string with the characters provided. * * This is useful when preparing an input array for ``c_ws_plugin__s2member_utils_arrays::in_regex_array()``. * * @package s2Member\Utilities * @since 3.5 * * @param str|array $value Either a string, an array, or a multi-dimensional array, filled with integer and/or string values. * @param str $beg A string value to wrap at the beginning of each value. * @param str $end A string value to wrap at the ending of each value. * @return str|array Either the input string, or the input array; after all data is wrapped up. */ public static function wrap_deep ($value = FALSE, $beg = FALSE, $end = FALSE) { return (is_array ($value) && !empty ($value)) ? array_map ("c_ws_plugin__s2member_utils_strings::wrap_deep", $value, array_fill (0, count ($value), $beg), array_fill (0, count ($value), $end)) : ((is_string ($value) && strlen ($value)) ? (string)$beg . (string)$value . (string)$end : ((is_array ($value)) ? $value : (string)$value)); } /** * Generates a random string with letters/numbers/symbols. * * @package s2Member\Utilities * @since 3.5 * * @param int $length Length of the randomly generated string. * @param bool $special_chars Defaults to true. If false, special chars are NOT included. * @param bool $extra_special_chars Defaults to false. If true, extra special chars are included. * @return str A randomly generated string, based on parameter configuration. */ public static function random_str_gen ($length = 12, $special_chars = TRUE, $extra_special_chars = FALSE) { $chars = "abcdefghijklmnopqrstuvwxyzABCDEFGHIJKLMNOPQRSTUVWXYZ0123456789"; $chars .= ($extra_special_chars) ? "-_ []{}<>~`+=,.;:/?|" : ""; $chars .= ($special_chars) ? "!@#$%^&*()" : ""; /**/ for ($i = 0, $random_str = ""; $i < $length; $i++) $random_str .= substr ($chars, mt_rand (0, strlen ($chars) - 1), 1); /**/ return $random_str; } /** * Highlights PHP, and also Shortcodes. * * @package s2Member\Utilities * @since 3.5 * * @param str $str Input string to be highlighted. * @return str The highlighted string. */ public static function highlight_php ($str = FALSE) { $str = highlight_string ($str, true); /* Start with PHP syntax highlighting first. */ /**/ return preg_replace_callback ("/(\[)(\/?)(_*s2If|s2Get|s2Member-[A-z_0-9\-]+)(.*?)(\])/i", "c_ws_plugin__s2member_utils_strings::_highlight_php", $str); } /** * Highlights Shortcodes. * * @package s2Member\Utilities * @since 3.5 * * @param array $m Array passed in from `preg_replace_callback()`. * @return str The highlighted string. */ public static function _highlight_php ($m = FALSE) { return '' . $m[0] . ''; } } } ?>