정규식 잘하시닌분조와주세요

정규식 잘하시닌분조와주세요

QA

정규식 잘하시닌분조와주세요

본문

네이버 파싱해서 보드에넣고있는데요

파싱은됫는데 파싱된 데이터를 입력하려고보니가 안되서질문드림니다

 

아래소스는 파싱된 페이지에서 소스보기했을때 저렇게나오는데요 

입력을하려고하니가 앞에 첫줄(빨간색부분)만 들어가고 나머지는 

안들어가지네요

 

<img src="http://postfiles1.naver.net/122930_01.jpg?type=w1"><br><img src="http://postfiles13.naver.net/122933_02.jpg?type=w1"><br><img src="http://postfiles6.naver.net/122935_03.jpg?type=w1"><br><img src="http://postfiles2.naver.net/122938_04.jpg?type=w1"><br><img src="http://postfiles9.naver.net/122941_05.jpg?type=w1"><br><img src="http://postfiles1.naver.net/122942_06.jpg?type=w1"><br><img src="http://postfiles3.naver.net/122944_07.jpg?type=w1"><br><img src="http://postfiles9.naver.net/122946_08.jpg?type=w1"><br>​

 

이거는 파싱할때 쓴소스임니다

 

​​$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui";
$contents = file_get_contents($url);
preg_match_all($pattern, $contents, $match);
foreach($match[0] as $key => $img) {
$val = substr($img, 0, -1);
$img2 = '<img src="'.$img.'">'."<br>";    //echo 햇을경우 잘보임......
 
$newpost[wr_content] = "$img2";           // 보드에 입력할때 첫줄만들가짐,..
 

이 질문에 댓글 쓰기 :

답변 6


$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui"; 
$contents = file_get_contents($url); 
preg_match_all($pattern, $contents, $match); 
foreach($match[0] as $key => $img) { 
$val = substr($img, 0, -1); 
$img2 = '<img src="'.$img.'">'."<br>";
$newpost[wr_content] .= "$img2"; 
}
$newpost[bo_table] = "free"; 
$newpost[wr_subject] = "$it_name"; 
$newpost[wr_link1] = "$url"; 
$newpost[mb_id] = 'admin'; 
$result = m3post($newpost); 
 

 

$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui"; 

$contents = file_get_contents($url); 
preg_match_all($pattern, $contents, $match); 
foreach($match[0] as $key => $img) { 
$val = substr($img, 0, -1); 
$img2 = '<img src="'.$img.'">'."<br>";

$newpost[wr_content] .= "$img2"; 
}
$newpost[bo_table] = "free"; 
$newpost[wr_subject] = "$it_name"; 

$newpost[wr_link1] = "$url"; 
$newpost[mb_id] = 'admin'; 
$result = m3post($newpost);  

해봤는데 똑같네요,ㅜ.ㅜ

맨앞에 빨간부분은 <img src="http://postfiles1.naver.net/122930_01.jpg?type=w1"><br>

입니다.​


<img src="http://postfiles1.naver.net/122930_01.jpg?type=w1"><br>

<img src="http://postfiles1.naver.net/122930_01.jpg?type=w1"><br>

이렇게나오네요...​ 아래소느도한번봐주실래요 아래거를바궈보니 위에이미지를 다가져오는데

게시글이 이미지숫자만큼 작성됨니다 이미지가 10개면 게시글 10개작성됨니다.

 

현제입력부분...

$row = sql_fetch("select count(*) as cnt from {$write_table} where wr_link1 = '$wr_link1'"); 

if($row['cnt']) return false; 

 

아래거로했을때는 이미지를 전부다가져오나 게시글이 이미지숫자만큼 작성되서 올라가네요

 //$row = sql_fetch("select count(*) cnt from {$write_table} where wr_content = '$wr_content'"); 

 //if($row['cnt']) return false;  

$row = sql_fetch("select count(*) as cnt from {$write_table} where wr_link1 = '$wr_link1'");
if($row['cnt']) return false;
이건 입력과는 관계없어 보이구요.
foreach()문의 블럭이 insert 이후에 닫히는 모양이군요. insert 이전으로 닫는괄호(})를 옮기셔야 할겁니다.

$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui";
$contents = file_get_contents($url);
preg_match_all($pattern, $contents, $match);
foreach($match[0] as $key => $img) {
$val = substr($img, 0, -1);
$img2 = '<img src="'.$img.'">'."<br>";

$newpost[bo_table] = "free";
$newpost[wr_subject] = "$it_name";
$newpost[wr_content] = "$img2";
$newpost[wr_content] .= "$img2";
$newpost[wr_link1] = "$url";
$newpost[mb_id] = 'admin';
$result = m3post($newpost);
}
?>
맨아래 닫히게해놧는데이리저리옴겨볼게요

같은상황이네요...

 

$pattern = "/http:\/\/(postfiles).*\.(jpg).?type=w1/Ui"; 

$contents = file_get_contents($url); 
preg_match_all($pattern, $contents, $match); 
foreach($match[0] as $key => $img) { 
$val = substr($img, 0, -1); 
$img2 = '<img src="'.$img.'">'."<br>"; 
}
$newpost[bo_table] = "free"; 
$newpost[wr_subject] = "$it_name"; 
$newpost[wr_content] = "$img2"; 
$newpost[wr_link1] = "$url"; 
$newpost[mb_id] = 'admin'; 
$result = m3post($newpost); 

?>  

 

혹시 저기 $img2를 $wr_1 부터 10까지 이미지1개씩 따로따로 불러올려면 foreach을어덯게 작성해야되는지요?

아니면 다른방법이라도....​

아래처럼 1개식잘라서 넣으면들어갈거같아서요

$newpost[wr_1] = "$img_1";

$newpost[wr_2] = "$mg_2";

$newpost[wr_3] = "$img_​3";

$newpost[wr_4] = "$mg_​4";

$newpost[wr_5] = "$mg_​5";

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

회원로그인

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