조회 수 507 추천 수 1 댓글 1
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
?

단축키

Prev이전 문서

Next다음 문서

크게 작게 위로 아래로 댓글로 가기 인쇄
Extra Form
라이선스 MIT
function hex2rgb($color)
{
    $color = str_replace('#', '', $color);
    $hex = strlen($color) == 3
        ? [$color[0].$color[0], $color[1].$color[1], $color[2].$color[2]]
        : [$color[0].$color[1], $color[2].$color[3], $color[4].$color[5]];

    list($r, $g, $b) = $hex;
    return sprintf(
        'rgb(%s, %s, %s)',
        hexdec($r), hexdec($g), hexdec($b)
    );
}

function rgb2hex($r, $g = null, $b = null)
{
    if(strpos($r, 'rgb') !== false || strpos($r, 'rgba') !== false)
    {
        if(preg_match_all('/\(([^\)]*)\)/', $r, $matches) && isset($matches[1][0]))
        {
            list($r, $g, $b) = explode(',', $matches[1][0]);
        }
        else
        {
            return false;
        }
    }

    $result = '';
    foreach([$r, $g, $b] as $c)
    {
        $hex = base_convert($c, 10, 16);
        $result .= ($c < 16) ? ('0'.$hex) : $hex;
    }

    return '#'.$result;
}



PHP 함수 모음 라이브러리를 만드려고 검색하는 도중 쓸만한 코드가 보여 업로드 합니다.

https://github.com/ngfw/Recipe 에 포함된 코드이며,  MIT 라이선스를 따릅니다.


  1. [PHP] 기상청 중기예보를 캐러셀로 보여주는 위젯 (매우 허접합니다 ㅠㅠ)

    Date2018.09.28 Category코드 By이니스프리 Views647
    Read More
  2. Cmd 에서 서비스 시작 / 종료하기

    Date2018.02.18 Category코드 ByProjectSE Views644
    Read More
  3. 브라우저 언어에 따라 다른 폴더를 사용하는 PHP 코드

    Date2017.10.10 Category코드 By네모 Views639
    Read More
  4. [아미나] 게시글을 작성하면 ID와 IP로 필터링하여 자동으로 랜덤 댓글을 남기기 (+랜덤 포인트)

    Date2018.11.18 Category코드 By이니스프리 Views634
    Read More
  5. [JS]클라이언트에서 Ip를 얻어보자

    Date2019.01.21 Category코드 ByHanam09 Views625
    Read More
  6. [PHP] 간단한 캐싱 클래스

    Date2018.12.06 Category코드 Bytitle: 황금 서버 (30일)humit Views605
    Read More
  7. 매우 특이한 버그

    Date2018.06.05 Category코드 Bytitle: 대한민국 국기gimmepoint Views569
    Read More
  8. Hello, World!를 출력해보자

    Date2018.04.21 Category코드 By네모 Views568
    Read More
  9. [Python] 모 정부기관 사이트 파싱 후 PC 통신처럼 열람하고 싶은 게시글 번호를 입력하면 내용을 보여주는 소스 (허접)

    Date2018.09.14 Category코드 By이니스프리 Views559
    Read More
  10. 내가 만든 사칙연산 계산기

    Date2018.05.11 Category코드 Bytitle: 대한민국 국기gimmepoint Views515
    Read More
  11. HEX를 RGB로, RGB를 HEX로 바꾸는 PHP 코드

    Date2018.05.05 Category코드 By네모 Views507
    Read More
  12. 파이선 셸에서 실행하면...?

    Date2018.07.22 Category코드 By제르엘 Views499
    Read More
  13. c 이진트리 전,중,후위 알고리즘

    Date2018.04.24 Category코드 Bytitle: 대한민국 국기gimmepoint Views495
    Read More
  14. 아주 간단한 기초 C++

    Date2018.04.21 Category코드 By제르엘 Views477
    Read More
  15. [JS] 클라이언트단 GET Parameter

    Date2019.11.16 Category코드 ByHanam09 Views468
    Read More
  16. JavaScript에서 파이썬 문자열 처리 함수 중 하나 (바인딩)를 구현

    Date2020.01.20 Category코드 BySeia Views465
    Read More
  17. Koa에서 자동으로 라우팅 채워주기

    Date2020.01.22 Category코드 BySeia Views439
    Read More
  18. C언어 삼중자를 이용한 코드

    Date2018.07.22 Category코드 Bytitle: 황금 서버 (30일)humit Views410
    Read More
  19. 내가 만든 함수 모음집

    Date2018.05.08 Category코드 Bytitle: 대한민국 국기gimmepoint Views382
    Read More
  20. 미완성 받아쓰기 (C)

    Date2018.04.20 Category코드 Bytitle: 대한민국 국기gimmepoint Views380
    Read More
Board Pagination Prev 1 2 3 4 Next
/ 4