아무도 저를 도울 수 있습니까?
text : 함수에서 만든 [RANDOM : 100,200] 번호가있는 샘플 텍스트입니다.
결과 : 함수에서 만든 숫자 153의 샘플 텍스트입니다.
이 패턴을 [RANDOM : 100,200]에서 100-200의 숫자로 검색하여 바꾸고 싶습니다.
모두 감사합니다 ..
$str = "this is my script [random:15;30] and I want to see if I found that.";
preg_match("/random:(.*)/", $str, $res);
print_r($res);
아마도 이런 것
$str = "this is my script [random:15;30] and I want to see if I found that.";
preg_match("/\[random:(\d+);(\d+)\]/", $str, $res);
$random = rand($res[1], $res[2]);
$str = str_replace($res[0], $random, $str);
echo $str;
이 기사는 인터넷에서 수집됩니다. 재 인쇄 할 때 출처를 알려주십시오.
침해가 발생한 경우 연락 주시기 바랍니다[email protected] 삭제
몇 마디 만하겠습니다