public static function getColoredString($string, $foreground_color = '', $background_color = '')
    {
        $colored_string = '';

        // Check if given foreground color exists
        if (isset(static::$foreground_colors[$foreground_color])) {
            $colored_string .= "\033[".static::$foreground_colors[$foreground_color].'m';
        }

        // Check if given background color exists
        if (isset(static::$background_colors[$background_color])) {
            $colored_string .= "\033[".static::$background_colors[$background_color].'m';
        }

        if ($colored_string) {
            // Add string and end coloring
            $colored_string .= $string."\033[0m";
        } else {
            $colored_string = $string;
        }

        return $colored_string;
    }
public static function getColoredString($string, $foreground_color = '', $background_color = '')
    {
        $colored_string = '';

        // Check if given foreground color exists
        if (isset(static::$foreground_colors[$foreground_color])) {
            $colored_string .= "\033[".static::$foreground_colors[$foreground_color].'m';
        }

        // Check if given background color exists
        if (isset(static::$background_colors[$background_color])) {
            $colored_string .= "\033[".static::$background_colors[$background_color].'m';
        }

        if ($colored_string) {
            // Add string and end coloring
            $colored_string .= $string."\033[0m";
        } else {
            $colored_string = $string;
        }

        return $colored_string;
    }
public static function getColoredString ( $ string , $ foreground_color = '' , $ background_color = '' ) { $ colored_string = '' ; // Check if given foreground color exists if ( isset ( static :: $ foreground_colors [ $ foreground_color ] ) ) { $ colored_string .= "\033[" . static :: $ foreground_colors [ $ foreground_color ] . 'm' ; } // Check if given background color exists if ( isset ( static :: $ background_colors [ $ background_color ] ) ) { $ colored_string .= "\033[" . static :: $ background_colors [ $ background_color ] . 'm' ; } if ( $ colored_string ) { // Add string and end coloring $ colored_string .= $ string . "\033[0m" ; } else { $ colored_string = $ string ; } return $ colored_string ; }
Returns colored string.

@param string $string           The string to applu color to
@param string $foreground_color The foreground color
@param string $background_color The background color

@return string
Returns colored string .