PHP | 태그 또는 멘션 소스 뽐아내기방법
페이지 정보
작성자 관리자 작성일18-01-12 16:52 조회1,140회 댓글0건관련링크
본문
요즘 대세인 샵과 멘션정보를 홈페이지나 SNS 볼수 있는데..
해당 #,@만 추출하는 정규식 함수입니다.
<!--//
function tag_string($string){
$re = '/(#[0-9a-zA-Z가-힣ㄱ-ㅎ]*)/ui';
$str = $string;
preg_match_all($re, $str, $matches);
$change = array();
foreach ( $matches[0] as $s ) $change[$s] = "<a href=''><strong style='color:#6699CC;'>".$s."</strong></a>";
echo strtr($str,$change).'';
}
function nickname_tag_string($string){
$re = '/(@[0-9a-zA-Z가-힣ㄱ-ㅎ]*)/ui';
$str = $string;
preg_match_all($re, $str, $matches);
$change = array();
foreach ( $matches[0] as $s ) $change[$s] = "<strong style='color:#aaa;'>".$s."</strong>";
echo strtr($str,$change).'';
}
//-->
해당 #,@만 추출하는 정규식 함수입니다.
<!--//
function tag_string($string){
$re = '/(#[0-9a-zA-Z가-힣ㄱ-ㅎ]*)/ui';
$str = $string;
preg_match_all($re, $str, $matches);
$change = array();
foreach ( $matches[0] as $s ) $change[$s] = "<a href=''><strong style='color:#6699CC;'>".$s."</strong></a>";
echo strtr($str,$change).'';
}
function nickname_tag_string($string){
$re = '/(@[0-9a-zA-Z가-힣ㄱ-ㅎ]*)/ui';
$str = $string;
preg_match_all($re, $str, $matches);
$change = array();
foreach ( $matches[0] as $s ) $change[$s] = "<strong style='color:#aaa;'>".$s."</strong>";
echo strtr($str,$change).'';
}
//-->
[주소복사] https://www.goodsweb.kr/?u=D41RFMrP
SNS 알리기
핀터레스트
텔레그램로
블로그로
페이스북
트위터
카카오스토리
카톡 공유
관련 블로그
로딩중