我想製作一個腳本,它將從一個字符列表中取一個隨機變量。每封信之前我有+ &
。這是我想出迄今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
您能給我們一個預期產出的例子嗎? –
刪除動作中的'#',不確定表單是否已發佈。 –
你還應該考慮一下這樣一個事實,即你在同一個循環中做了兩次回聲,可能是它的錯誤。 – lfxgroove