나는 이해할 수 없다 HTML로,String to HTML? 아래의 코드는 문자열로 문자열을 반환하지만 왜
function en_code($string)
{
# find the match of [br] = a break = <br>
$output = preg_replace('/\[(?: |\s)*([br]+)(?: |\s)*\]/', '<$1 />', $string);
# return the result
return $output;
}
$string = 'Wallace and Gromit\'s Children Foundation the whole campaign was exemplary, showing true professionalism, creativity and an amazing understanding of what makes a strong news story.\'[br][br]Wallace & Gromit\'s Children\'s Foundation';
echo en_code($string);
반환
Wallace and Gromit's Children Foundation the whole campaign was
exemplary, showing true professionalism, creativity and an amazing
understanding of what makes a strong news story.'<br /><br />Wallace &
Gromit's Children's Foundation
하지만이 같은 반환해야합니다,
Wallace and Gromit 's Children Foundation 전체 캠페인은 참된 전문성과 창의력 그리고 놀랄만 한 모습을 보여주는 의 모범이되었습니다. understandi 강력한 뉴스 스토리를 만들어 낸 것. "
월러스 & 그로밋의 어린이 재단은
내가 뭘하려고하는 기능에 <br />
에 [br]
을 변환하는 것입니다.
아이디어가 있으십니까?
HTML을 원한다면 왜 '>'과 '<'으로 번역하고 있습니까? (> '& '<') –
을 사용하지 않는 경우 [이 테스트] (http://regexr.com?2uu3p)를 참조하십시오. 어떻게'> '및'< '을 html로 변환 할 수 있습니까? – laukok
'str_replace ('[br]', '
', $ string)'할 때 복잡한 정규식을 사용하는 이유는 무엇입니까? –