<?php
/**
* @author ДоХтор <drzoom@mail.ru>
*
* @param string $string
* @return string
*/
function gradient($string){
static $colors = [
'492702', '5B2F0B', '734119', '856449', '988575', '8B947E',
'7D8C67', '7E9C50', '72A725', '77BA13', '6AA80D', '4C7B06',
'456F07', '365507', '2C4605', '223603', '1D2F03', '052E1C',
'043A22', '0B5031', '085B36', '0E6E42', '0D8C53', '4DAC81',
'5FB88F', '8BB4A1', '679681', '687F75', '51675D', '5D5F5E',
'4E5D5C', '567776', '575262', '554A6D', '54427B', '5B39A2',
'4F338B', '442684', '351777', '280B67', '220957', '15043A',
'130434', '17021C', '220329', '2C0336', '360642', '3C044A',
'490859', '530D65', '550B68', '6A157F', 'A122C1', 'DC1097',
'FA0E8F', 'FA054F'
];
$chars = preg_split('||u', $string, -1, PREG_SPLIT_NO_EMPTY);
$return = '';
foreach($chars as $char) {
$return .= '<span style="color: #'.$colors[array_rand($colors)].';">'.$char.'</span>';
}
return $return;
}
echo gradient('some text');
echo gradient('another text');