문자 목록에서 임의의 변수를 취하는 스크립트를 만들려고합니다. 나는 각 편지의 앞에 + &
가있다. 이것은 내가 지금까지PHP 배열과 html 형식
<form action="#" method="post">
<input type="text" name="text">
<input type="submit" name="submit">
</form>
<?php
if (isset($_POST['submit'])) {
$str = $_POST["text"];
$arr1 = str_split($str);
foreach ($arr1 as $value)
{
$length = 1;
$chars = '46eab95';
$charslength = strlen($chars);
$randomstring = '';
for ($i = 0; $i < $length; $i++) $randomstring .= substr($chars, rand(0, $charslength - 1), 1);
echo $randomstring;
echo "&" . $randomstring . $value;
}
}
?>
함께 온 것입니다 그러나 그것은 단지 망쳐하고 내가 안녕하세요이 나오면 무엇을 할 수 있도록하려고 할 때 예를 들어, 작동하지 않습니다 6&6h4&4e4&4l6&6l5&5o
예상 출력의 예를 들려 줄 수 있습니까? –
당신의 행동에서'#'을 제거하십시오, 당신의 폼이 게시되었는지 확신하지 못합니다. –
같은 루프에서 두 번 echo하는 사실에 대해서도 생각해 봐야한다. – lfxgroove