2014-08-30 2 views
-2

텍스트를 HTML로 변환하는 방법? 내가 만들고 싶어

간단한 텍스트 내가이 작업을 수행하는 방법이

<p><span>"Vehicle Title Not Required/Not Issued&nbsp;</span><br /><br /><span>&bull;1962 and older year model vehicles&nbsp;</span><br /><span>&bull;Agricultural, horticultural or livestock raising equipment or vehicles that are not required to be registered&nbsp;</span><br /><span>&bull;Airplanes, aircraft&nbsp;</span><br /><span>&bull;All terrain vehicles, off-road vehicles&nbsp;</span><br /><span>&bull;Boat trailers&nbsp;</span><br /><span>&bull;Boats, watercraft"&nbsp;</span></p> 

로 변환 할이

"Vehicle Title Not Required/Not Issued 

•1962 and older year model vehicles 
•Agricultural, horticultural or livestock raising equipment or vehicles that are not required to be registered 
•Airplanes, aircraft 
•All terrain vehicles, off-road vehicles 
•Boat trailers 
•Boats, watercraft" 

같은 것 HTML로 텍스트를 변환 싶은 생각?

+1

는 아무것도 스스로 할 시도 해 봤나 :

나는이 일이 지속적으로 일을 찾았나요? – hindmost

답변

0

간단한 : 대신

<?php 
    $input = " ... your text from above ..."; 
    echo "<p><span>"; 
    echo str_replace("\n", "</span><br /><br /><span>", $input); 
    echo "</span></p>"; 
?> 
0

사용 목록 요소입니다.

<p><span>&quot;Vehicle Title Not Required/Not Issued</span><br> 
<ul> 
<li>1962 and older year model vehicles</li> 
<li>Agricultural, horticultural or livestock raising equipment or vehicles that are not required to be registered</li> 
<li>Airplanes, aircraft </li> 
<li>All terrain vehicles, off-road vehicles </li> 
<li>Boat trailers </li> 
<li>Boats, watercraft&quot;</li> 
</ul> 

PHP 코드 (당신은 그것을 사용 할 수 있습니다) :

<?php 
echo " 
<p><span>&quot;Vehicle Title Not Required/Not Issued</span><br> 
<ul> 
<li>1962 and older year model vehicles</li> 
<li>Agricultural, horticultural or livestock raising equipment or vehicles that are not required to be registered</li> 
<li>Airplanes, aircraft </li> 
<li>All terrain vehicles, off-road vehicles </li> 
<li>Boat trailers </li> 
<li>Boats, watercraft&quot;</li> 
</ul> 
"; 
?> 
1

난 당신이 PHP에서이 작업을 수행 할 태그에서 가정합니다.

비슷한 일을하는 몇 가지 PHP 함수 (예 : htmlencode 및 htmlentities)가 있습니다.

mb_convert_encoding (반드시 htmlspecialchars ($ 문자열), 'HTML 엔티티')

+0

친애하는 각하, 나는 PHP의 문서에서 예제를 시도하지만 아무것도 작동하지 굵게는"; // 출력 : '견적'은 <입니다. > 굵게 </b > echo htmlentities ($ str); // 출력하십시오 ' 견적 '이다 <B> 굵은 </B > 에코를 htmlentities ($ STR, ENT_QUOTES); ?> – user2778768

+0

안녕하세요. 문자열이 HTML 형식 (예 : >)이거나 (>)이 아니라는 것을 알아야합니다. 앞서 언급 한 기능을 사용하여 일반 텍스트를 HTML로 변환 할 수 있습니다. 문자열 값이 HTML 인 경우 htmlentities와 같은 함수를 사용하여 다시 인코딩하면 안됩니다.이 이중 인코딩은 일반 텍스트 인 것처럼 HTML을 읽으므로 파손됩니다. –

+0

xampp + windows 8.1을 사용 중입니다.이 설정은 내 설정에서는 작동하지 않지만, http : //sandbox.onlinephpfunctions.com/code/5c4a32bf99aa8fd6246c4a77132a023d32945363 여기에서 문제가 해결되었습니다. – user2778768

관련 문제