public static function Rgb2Hex( $r, int $g = -1, int $b = -1 )
   {

      if ( \is_array( $r ) )
      {

         if ( \count( $r ) != 3 )
         {
            return false;
         }

         \array_change_key_case( $r, \CASE_LOWER );

         if ( isset( $r[ 'r' ] ) && isset( $r[ 'g' ] ) && isset( $r[ 'b' ] ) )
         {
            $g = $r[ 'g' ];
            $b = $r[ 'b' ];
            $r = $r[ 'r' ];
         }
         else if ( isset( $r[ 'red' ] ) && isset( $r[ 'green' ] ) && isset( $r[ 'blue' ] ) )
         {
            $g = $r[ 'green' ];
            $b = $r[ 'blue' ];
            $r = $r[ 'red' ];
         }
         else
         {
            $rgb = $r;
            list( $r, $g, $b ) = $rgb;
         }

      }
      else if ( \preg_match( '~^(rgb\s*\()?(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)?$~', (string) $r, $m ) )
      {

         list( $ignore, $r, $g, $b ) = $m;
         if ( ! empty( $ignore ) )
         {
            unset( $ignore );
         }

      }
      else if ( ! \is_int( $r ) )
      {

         return false;

      }
      $r1 = \intval( $r );
      $g1 = \intval( $g );
      $b1 = \intval( $b );
      $r  = \dechex( $r1 < 0 ? 0 : ( $r1 > 255 ? 255 : $r1 ) );
      $g  = \dechex( $g1 < 0 ? 0 : ( $g1 > 255 ? 255 : $g1 ) );
      $b  = \dechex( $b1 < 0 ? 0 : ( $b1 > 255 ? 255 : $b1 ) );

      return \sprintf( '#%02s%02s%02s', $r, $g, $b );

   }
public static function Rgb2Hex( $r, int $g = -1, int $b = -1 )
   {

      if ( \is_array( $r ) )
      {

         if ( \count( $r ) != 3 )
         {
            return false;
         }

         \array_change_key_case( $r, \CASE_LOWER );

         if ( isset( $r[ 'r' ] ) && isset( $r[ 'g' ] ) && isset( $r[ 'b' ] ) )
         {
            $g = $r[ 'g' ];
            $b = $r[ 'b' ];
            $r = $r[ 'r' ];
         }
         else if ( isset( $r[ 'red' ] ) && isset( $r[ 'green' ] ) && isset( $r[ 'blue' ] ) )
         {
            $g = $r[ 'green' ];
            $b = $r[ 'blue' ];
            $r = $r[ 'red' ];
         }
         else
         {
            $rgb = $r;
            list( $r, $g, $b ) = $rgb;
         }

      }
      else if ( \preg_match( '~^(rgb\s*\()?(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)?$~', (string) $r, $m ) )
      {

         list( $ignore, $r, $g, $b ) = $m;
         if ( ! empty( $ignore ) )
         {
            unset( $ignore );
         }

      }
      else if ( ! \is_int( $r ) )
      {

         return false;

      }
      $r1 = \intval( $r );
      $g1 = \intval( $g );
      $b1 = \intval( $b );
      $r  = \dechex( $r1 < 0 ? 0 : ( $r1 > 255 ? 255 : $r1 ) );
      $g  = \dechex( $g1 < 0 ? 0 : ( $g1 > 255 ? 255 : $g1 ) );
      $b  = \dechex( $b1 < 0 ? 0 : ( $b1 > 255 ? 255 : $b1 ) );

      return \sprintf( '#%02s%02s%02s', $r, $g, $b );

   }
public static function Rgb2Hex ( $ r , int $ g = - 1 , int $ b = - 1 ) { if ( \ is_array ( $ r ) ) { if ( \ count ( $ r ) != 3 ) { return false ; } \ array_change_key_case ( $ r , \ CASE_LOWER ) ; if ( isset ( $ r [ 'r' ] ) && isset ( $ r [ 'g' ] ) && isset ( $ r [ 'b' ] ) ) { $ g = $ r [ 'g' ] ; $ b = $ r [ 'b' ] ; $ r = $ r [ 'r' ] ; } else if ( isset ( $ r [ 'red' ] ) && isset ( $ r [ 'green' ] ) && isset ( $ r [ 'blue' ] ) ) { $ g = $ r [ 'green' ] ; $ b = $ r [ 'blue' ] ; $ r = $ r [ 'red' ] ; } else { $ rgb = $ r ; list ( $ r , $ g , $ b ) = $ rgb ; } } else if ( \ preg_match ( '~^(rgb\s*\()?(\d{1,3}),\s*(\d{1,3}),\s*(\d{1,3})\)?$~' , ( string ) $ r , $ m ) ) { list ( $ ignore , $ r , $ g , $ b ) = $ m ; if ( ! empty ( $ ignore ) ) { unset ( $ ignore ) ; } } else if ( ! \ is_int ( $ r ) ) { return false ; } $ r1 = \ intval ( $ r ) ; $ g1 = \ intval ( $ g ) ; $ b1 = \ intval ( $ b ) ; $ r = \ dechex ( $ r1 < 0 ? 0 : ( $ r1 > 255 ? 255 : $ r1 ) ) ; $ g = \ dechex ( $ g1 < 0 ? 0 : ( $ g1 > 255 ? 255 : $ g1 ) ) ; $ b = \ dechex ( $ b1 < 0 ? 0 : ( $ b1 > 255 ? 255 : $ b1 ) ) ; return \ sprintf ( '#%02s%02s%02s' , $ r , $ g , $ b ) ; }
Converts a RGB array or the 3 r, g, b values into a hexadecimal color representation.

@param  array|integer $r RGB Array or the red bit value.
@param  int           $g The green bit value.
@param  int           $b The blue bit value
@return string|FALSE
Converts a RGB array or the 3 r g b values into a hexadecimal color representation .