php출력 문의

php출력 문의

QA

php출력 문의

본문

 

https://sir.kr/pg_tip/16019

슈와이님 팁인데요.


저기에서 아래 코드가 출력 같은데요.

new UrlChange($search, $replace);

위 출력 코드를 아래처럼 담으려면 어떻게 해야할까요?

 

$aaa = "출력값"; 
이런식으로요.

 

이 질문에 댓글 쓰기 :

답변 1

$value 를 추가 하였습니다 

 

class UrlChange {
    var $matches, $i = 0, $regex = '/(?<=src=")[^"]+/' , $value="" ;
    function __construct($search, $replace) {
        preg_match_all($this->regex, $search, $matches);
        $this->matches = $matches[0]; 
        $this->value=preg_replace_callback($this->regex, array($this, 'call'), $replace);
    }
    function call($m) { return $this->matches[$this->i++]; }
    function getData(){return $this->value;}
}
$bbb= new UrlChange($search, $replace);
$aaa = $bbb->getData();
echo $aaa;

답변을 작성하시기 전에 로그인 해주세요.
전체 16,737
QA 내용 검색

회원로그인

(주)에스아이알소프트 / 대표:홍석명 / (06211) 서울특별시 강남구 역삼동 707-34 한신인터밸리24 서관 1404호 / E-Mail: admin@sir.kr
사업자등록번호: 217-81-36347 / 통신판매업신고번호:2014-서울강남-02098호 / 개인정보보호책임자:김민섭(minsup@sir.kr)
© SIRSOFT