mirror of
https://github.com/wbbaddons/Tims-Chat.git
synced 2024-10-31 14:10:08 +00:00
Adding UTF-8 save version of str_split
This commit is contained in:
parent
f6d8273d86
commit
c5821e543b
@ -30,7 +30,7 @@ class ChatUtil {
|
|||||||
* @returen string
|
* @returen string
|
||||||
*/
|
*/
|
||||||
public static function gradient($string, $start, $end) {
|
public static function gradient($string, $start, $end) {
|
||||||
$string = str_split($string);
|
$string = self::str_split($string);
|
||||||
$r = (int) ((($start >> 16 & 255) - ($end >> 16 & 255)) / (count($string) - 1));
|
$r = (int) ((($start >> 16 & 255) - ($end >> 16 & 255)) / (count($string) - 1));
|
||||||
$g = (int) ((($start >> 8 & 255) - ($end >> 8 & 255)) / (count($string) - 1));
|
$g = (int) ((($start >> 8 & 255) - ($end >> 8 & 255)) / (count($string) - 1));
|
||||||
$b = (int) ((($start & 255) - ($end & 255)) / (count($string) - 1));
|
$b = (int) ((($start & 255) - ($end & 255)) / (count($string) - 1));
|
||||||
@ -43,6 +43,22 @@ public static function gradient($string, $start, $end) {
|
|||||||
return $result;
|
return $result;
|
||||||
}
|
}
|
||||||
|
|
||||||
|
/**
|
||||||
|
* Splits a string into smaller chunks.
|
||||||
|
* UTF-8 safe version of str_split().
|
||||||
|
*
|
||||||
|
* @param string $string
|
||||||
|
* @param integer $length
|
||||||
|
* @return array<string>
|
||||||
|
*/
|
||||||
|
public static function str_split($string, $length = 1) {
|
||||||
|
$result = array();
|
||||||
|
for ($i = 0, $max = StringUtil::length($string); $i < $max; $i += $length) {
|
||||||
|
$result[] = StringUtil::substring($string, $i, $length);
|
||||||
|
}
|
||||||
|
return $result;
|
||||||
|
}
|
||||||
|
|
||||||
/**
|
/**
|
||||||
* Creates an interval out of a string with modifiers.
|
* Creates an interval out of a string with modifiers.
|
||||||
* Modifiers may be mixed. Valid modifiers are: _s_econd, _h_our, _d_ay, _w_week, _m_onth, _y_ear
|
* Modifiers may be mixed. Valid modifiers are: _s_econd, _h_our, _d_ay, _w_week, _m_onth, _y_ear
|
||||||
|
Loading…
Reference in New Issue
Block a user