# iframe 태그를 추출한다.
//preg_match_all("/(<(iframe+)[^>]*>)(.*?)(<\/\\2>)/", $wr_content, $matches);
preg_match_all("/(<(iframe+)([^>]*)>)(.*?)(<\/(iframe)>)/", $wr_content, $matches);
if(is_array($matches[3]) == true && count($matches[3]) > 0) {
// 태그가 있음
} else {
// 태그가 없음
}
# 추출한 결과를 확인
print_r2($matches);
[PHP] 정규식으로 태그 추출하기
그누보드 스킨을 수정하다가 생성한 코드
[PHP] 유니코드 한글 단어를 첫글자(초성)를 기준으로 가, 나, 다, ... 분류로 나누기
# 한글단어의 초성을 기준으로 가,나,다로 구분한다. [사용처 : 단어사전 등의 색인 검색]
if( ! function_exists('check_unicode_ord')) {
# 단어의 초성을 기준으로 가/나/다 구분하는 함수
function check_unicode_ord($string) {
$h = unicode_ord($string);
if($h >= 44032 && $h <= 45207) return "가";
if($h >= 45208 && $h <= 45795) return "나";
if($h >= 45796 && $h <= 46971) return "다";
if($h >= 46972 && $h <= 47559) return "라";
if($h >= 47560 && $h <= 48147) return "마";
if($h >= 48148 && $h <= 49323) return "바";
if($h >= 49324 && $h <= 50499) return "사";
if($h >= 50500 && $h <= 51087) return "아";
if($h >= 51088 && $h <= 52263) return "자";
if($h >= 52264 && $h <= 52851) return "차";
if($h >= 52852 && $h <= 53439) return "카";
if($h >= 53440 && $h <= 54027) return "타";
if($h >= 54028 && $h <= 54615) return "파";
if($h >= 54616 && $h <= 55203) return "하";
return "기타";
}
function unicode_ord($string) {
$h = ord($string{0});
if ($h <= 0x7F) {
return $h;
} else if ($h < 0xC2) {
return false;
} else if ($h <= 0xDF) {
return ($h & 0x1F) << 6 | (ord($string{1}) & 0x3F);
} else if ($h <= 0xEF) {
return ($h & 0x0F) << 12 | (ord($string{1}) & 0x3F) << 6 | (ord($string{2}) & 0x3F);
} else if ($h <= 0xF4) {
return ($h & 0x0F) << 18 | (ord($string{1}) & 0x3F) << 12 | (ord($string{2}) & 0x3F) << 6 | (ord($string{3}) & 0x3F);
} else {
return false;
}
}
}
사용방법
$kr_key = check_unicode_ord($string);
// '도라지' => '다'
// '백화점' => '바'
[css] [css selector] :nth-child 사용하기
<style type="text/css">
ul.test li { display:block; width:40px; height:40px; float:left; margin:0 15px 15px 0; }
ul.test li:nth-child(1) { background:#ff0; } /* 지정한 1개만 */
ul.test li:nth-child(3n+1) { border:1px solid #f00; } /* 규칙적으로 (3개마다) */
ul.test li:nth-child(-n+5) { color:blue; font-weight:bold; } /* 앞에서부터 계산(~ 5) */
ul.test li:nth-child(n+17) { color:red; font-weight:bold; } /* 뒤에서부터 계산(18 ~) */
ul.test li:nth-child(n+11):nth-child(-n+15) { background:#6ff; } /* 범위로 계산(11 ~ 15) */
</style>
- 1
- 2
- 3
- 4
- 5
- 6
- 7
- 8
- 9
- 10
- 11
- 12
- 13
- 14
- 15
- 16
- 17
- 18
- 19
- 20
:nth-child(odd) 홀수
:nth-child(even) 짝수
:nth-last-child() 뒤에서부터 계산한다.
[php] [mysql] SET 타입과 비트연산 사용하기
mysql의 SET 타입은 여러개의 값을 한번에 가질 수 있는 데이터 타입이다.
예를 들어 [관심분야 : A, B, C, D, E, F, ...] 가 있을 때 (복수선택 가능)
각각을 개별 칼럼에 저장하는 것보다는
하나의 칼럼에 합쳐서 저장하는 것이 검색기능에서 월등히 좋다.
DB에 저장할 경우에는 정수값을 할당하거나 텍스트 'A,C,E' 를 할당할 수 있다.
A = 1
A, B = 1 + 2 = 3
A, B, C = 1 + 2 + 4 = 7
이 값들은 결국 2의 제곱수 즉 bit 값이 된다.
SQL 질의문 예시 : 단순히 질의하는 경우
SELECT col_set FROM tbl_name;
// col_set = "A,B,C"; (문자열)
SELECT col_set+0 AS col_dec FROM tbl_name;
// col_dec = 7; (십진수)
SQL 질의문 예시 : 비트연산으로 조건검색을 하는 경우
SELECT * FROM tbl_name WHERE col_set & 1 > 0; // A를 포함한 경우
SELECT * FROM tbl_name WHERE col_set & 2 > 0; // B를 포함한 경우
SELECT * FROM tbl_name WHERE col_set & 4 > 0; // C를 포함한 경우
SELECT * FROM tbl_name WHERE col_set & 7 > 0; // A+B+C를 포함한 경우
PHP에서 사용하는 경우
if( (7 & 1) > 0 ) // 결과 true
if( (7 & 2) > 0 ) // 결과 true
if( (7 & 8) > 0 ) // 결과 false
* 주의 : 비트연산(&)을 반드시 괄호로 감싸줘야 함
관심분야 선택 기능을 위한 변수 생성
$col_array = array(
1 => 'A',
2 => 'B',
4 => 'C',
8 => 'D',
16 => 'E',
.... (2의 제곱수로 증가함)
);
# 관심분야를 선택하는 화면
foreach($col_array as $key=>$val) {
if( ($db_value_dec & $key) > 0 ) {
// 선택된 상태임
}
}
예를 들어 [관심분야 : A, B, C, D, E, F, ...] 가 있을 때 (복수선택 가능)
각각을 개별 칼럼에 저장하는 것보다는
하나의 칼럼에 합쳐서 저장하는 것이 검색기능에서 월등히 좋다.
DB에 저장할 경우에는 정수값을 할당하거나 텍스트 'A,C,E' 를 할당할 수 있다.
A = 1
A, B = 1 + 2 = 3
A, B, C = 1 + 2 + 4 = 7
이 값들은 결국 2의 제곱수 즉 bit 값이 된다.
SQL 질의문 예시 : 단순히 질의하는 경우
SELECT col_set FROM tbl_name;
// col_set = "A,B,C"; (문자열)
SELECT col_set+0 AS col_dec FROM tbl_name;
// col_dec = 7; (십진수)
SQL 질의문 예시 : 비트연산으로 조건검색을 하는 경우
SELECT * FROM tbl_name WHERE col_set & 1 > 0; // A를 포함한 경우
SELECT * FROM tbl_name WHERE col_set & 2 > 0; // B를 포함한 경우
SELECT * FROM tbl_name WHERE col_set & 4 > 0; // C를 포함한 경우
SELECT * FROM tbl_name WHERE col_set & 7 > 0; // A+B+C를 포함한 경우
PHP에서 사용하는 경우
if( (7 & 1) > 0 ) // 결과 true
if( (7 & 2) > 0 ) // 결과 true
if( (7 & 8) > 0 ) // 결과 false
* 주의 : 비트연산(&)을 반드시 괄호로 감싸줘야 함
관심분야 선택 기능을 위한 변수 생성
$col_array = array(
1 => 'A',
2 => 'B',
4 => 'C',
8 => 'D',
16 => 'E',
.... (2의 제곱수로 증가함)
);
# 관심분야를 선택하는 화면
foreach($col_array as $key=>$val) {
if( ($db_value_dec & $key) > 0 ) {
// 선택된 상태임
}
}
[swiper] 슬라이드에 이미지 및 텍스트 올리기
<div id="banner" class="swiper-container">
<ul class="swiper-wrapper">
<li class="swiper-slide" data-left="0"><img src="/images/main/visual01.jpg" alt=""></li>
<li class="swiper-slide" data-left="0"><img src="/images/main/visual01.jpg" alt=""></li>
<li class="swiper-slide" data-left="0"><img src="/images/main/visual01.jpg" alt=""></li>
</ul>
<div class="swiper-pagination"></div>
</div>
$(document).ready(function(){
//initialize swiper when document ready
var mySwiper = new Swiper ('.swiper-container', {
effect: 'fade',
fadeEffect: { crossFade:false, },
speed: 2500,
autoplay: true,
loop: true,
navigation: {
nextEl: '.swiper-button-next',
prevEl: '.swiper-button-prev',
},
pagination: {
el: '.swiper-container .swiper-pagination',
clickable: true,
},
});
});
/* 슬라이드 가로크기에 반응. 이미지를 자르고, 슬라이드의 중앙에 위치시킴 */
.swiper-slide { position:relative; width:100%; height:592px; overflow:hidden; }
.swiper-slide img { position:relative; display:block; width:1920px; height:592px; left:50%; margin-left:-960px; transform:scale(1.2,1.2); transition:all 0.5s; max-width:2000px; }
.swiper-slide.swiper-slide-active img { transform:scale(1.0,1.0); transition:all 1s; }
슬라이드가 1920px보다 작은 경우에는 이미지를 슬라이드의 가로 중앙에 위치시킨다.
left:50%; margin-left:-960px;이미지를 1.2배 확대한 크기로 생성하고,
슬라이드가 active 상태인 경우만 원본 크기로 변경시킨다.
transform:scale(1.2,1.2); transition:all 0.5s;
transform:scale(1.0,1.0); transition:all 1s;
[jquery] 부모창의 엘리먼트에 접근하기
프레임(iframe)인 경우
팝업인 경우
$("#id", parent.document).val(text); // 2가지 모두 가능함
window.parent.$("#id").val(text);
팝업인 경우
$("#id", opner.document).val(text);
window.opner.$("#id").val(text);
[PHP] 디렉토리가 존재하는지, 쓰기권한이 있는지 미리 검사
1. 디렉토리가 있는지 검사한다.
2. 디렉토리에 쓰기권한이 있는지 검사한다.
2. 디렉토리에 쓰기권한이 있는지 검사한다.
$dir = "/home/www/dir/upload";
if(is_dir($dir)==false) {
echo "디렉토리가 존재하지 않습니다."; exit;
}
if(is_writable($dir)==false) {
echo "디렉토리에 쓰기권한이 없습니다."; exit
}
피드 구독하기:
글 (Atom)
[SSL] [letsencrypt] [certbot] 와일드카드 인증서 발급하기
1. 환경 ubuntu 20.x nginx 2. 설치 apt-get install letsencrypt -y 3. 인증서 발급 ; example.com 도메인에 대해 와일드카드 인증서를 발급받는다. certbot certonly --ma...
-
<ul> <li>리스트 : 현재의 SQL문에 조건 추가 (상태처리값에 따른 구분 필요함)</li> <li>삭제 : 개별삭제, 선택삭제, 전체삭제</li> <li>견적...
-
box-shadow: h-offset(오른쪽) v-offset(아래쪽) blur spread color; box-shadow:1px 0 0 0 #aaaaaa; [오른쪽 1px 효과) box-shadow:0 1px 0 0 #aaaaaa; [아래쪽 1...
-
<link rel="stylesheet" href="https://cdnjs.cloudflare.com/ajax/libs/Swiper/4.3.3/css/swiper.min.css"> <script...