2017-10-19 113 views
2

我遇到了問題,我希望隨時重複類$的密碼,因爲$ intcount的數目是。你能不能告訴我怎麼做? f1。我附和4個隨機單詞,如果$ intcount是4,5字如果5等等等等在php中執行一個回顯或類x次

<?php 

$csv = array_map('str_getcsv', file('gen.csv')); 
$count = $_GET['count']; 
$intcount = (int)$count; 
$min = 0; 
$max = 4; 
$rand = mt_rand($min , $max); 

$out = $csv[$rand][$rand]; 

$password = $out; 

// var_dump($count); 
// var_dump($intcount); 
// 
// echo $count . "\n <br>"; 
// echo $password * $intcount; 
// 
// for ($i=0; $i < $intcount ; $i++) { 
//  echo $password; 
// } 

?> 

註釋代碼並不需要保持一定。

謝謝:)

+0

哪裏是'被定義$ password'? – mega6382

+0

>定義$密碼的位置在哪裏? 修正了這個問題,對不起。 – Bob

回答

1

你需要創建一個像循環內的$rand

$csv = array_map('str_getcsv', file('gen.csv')); 
$count = $_GET['count']; 
$intcount = (int)$count; 
$min = 0; 
$max = 4; 

for ($i=0; $i < $intcount ; $i++) 
{ 
    $rand = mt_rand($min, $max); 
    $password = $csv[$rand][$rand]; 
    echo $password; 
} 
+0

完美的作品,非常感謝。將盡快接受答案。 – Bob