형님들 치환이 안됩니다;

형님들 치환이 안됩니다;

QA

형님들 치환이 안됩니다;

답변 1

본문

src="../../data/abc.jpg"

src="../data/def.jpg"


위에서 

../../  두개일떄랑 ../ 한개일떄를   www.naver.com/  으로 치환하려면

 

$a = array ('../../'  , '../'  ); 

$b= array ('www.naver.com/' , 'www.naver.com/' );
 str_replace(   $a ,  $b ,  $result ); 

 

요런식으로 하는게 아니었나요?

이 질문에 댓글 쓰기 :

답변 1

http://php.net/manual/kr/function.str-replace.php

인자 순서가 찾을 문자, 바꿀문자, 문자열 순입니다.

 

아래는 배열 사용시 예제

 

// 결과: You should eat pizza, beer, and ice cream every day
$phrase  "You should eat fruits, vegetables, and fiber every day.";
$healthy = array("fruits""vegetables""fiber");
$yummy   = array("pizza""beer""ice cream");

$newphrase str_replace($healthy$yummy$phrase);

 

 

답변을 작성하시기 전에 로그인 해주세요.
QA 내용 검색
질문등록
전체 24
© SIRSOFT
현재 페이지 제일 처음으로