htmlentities()
변수를 인코딩 할 때 그것은 매력처럼 작동하지만 배열과 동일한 작업을 수행하면 빈 배열이 반환됩니다. 내가 array_map()
을 사용하려했지만 같은 이야기입니다. 인코딩을 ISO-8859-1
및 UTF-8
으로 전환하려고했지만 성공하지 못했습니다. 그것은 일하고 싶지 않습니다. 그것은 다음과 같은 출력을 생성htmlentities() 배열과 함께 사용하면 빈 문자열을 반환합니다
<html>
<head>
<title>Signup</title>
</head>
<body>
<form name="signup" method="POST" action="form.php">
<fieldset>
<legend><p style="color:red; font-size:16px">Sports</p></legend>
<ul>
<li>
<input type="checkbox" name="sports[]" value="soccer">
<label for="soccer">Soccer</label>
</li>
<li>
<input type="checkbox" name="sports[]" value="water_polo">
<label for="water_polo">Water polo</label>
</li>
<li>
<input type="checkbox" name="sports[]" value="tennis">
<label for="tennis">Tennis</label>
</li>
<li>
<input type="checkbox" name="sports[]" value="volleyball">
<label for="volleyball">Volleyball</label>
</li>
</ul>
</fieldset>
</form>
<?php
$sports = htmlentities($_POST["sports"], ENT_COMPAT, 'ISO-8859-15');
$count = count($sports);
if($count == 0) {
echo "You don't play any sports.<br>";
} else {
echo "You like playing: ";
foreach($sports as $s) {
if(--$count == 0) {
echo "<span style='color:red'>$s</span>.<br>";
break;
} else {
echo "<span style='color:red'>$s</span>, ";
}
}
}
?>
</body>
</html>
:
You don't play any sports.
(가) 내 배열을 인코딩 할 수 없습니다를 htmlentities 의미
여기에 코드입니다.
양식/입력 형식은 무엇입니까? array_map()을 어떻게 사용 했는가? –
['htmlentities()'] (http://php.net/manual/de/function.htmlentities.php)는 배열을 허용하지 않습니다. – simon
@simon 나는 OP가 독일어를 이해할 수 있을지 의심 스럽다 .-) PHP 웹을 참조 할 때 http://php.net/manual/en/function.htmlentities.php를 사용한다. –