php출력 문의
본문
슈와이님 팁인데요.
저기에서 아래 코드가 출력 같은데요.
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;
답변을 작성하시기 전에 로그인 해주세요.