2016-11-11 53 views
-2

我想打印custom_question不重複,它custom_question_answer在PHP中使用循環如下如何不重複迭代在PHP

enter image description here

+0

你嘗試過什麼嗎? –

+0

我加入了兩張表並得到了上述結果。但爲了顯示我有問題 – Raman

+0

爲了給你一個很好的答案,它可以幫助我們,如果你有一個問題,如果你還沒有看過。如果你可以提供[mcve],它可能也很有用。 – Mat

回答

0

可能有助於給你的分貝 鏈接,並獲得更清晰關於的想法。

<?php 
$arr = $arr_history = array("1stQuestion?","2ndQuestion?","3rdQuestion?","4thQuestion?"); 

for ($i = 0; $i < count($arr); $i++) 
{ 
    if (empty($arr_history)){ $arr_history = $arr; } 
    $key = array_rand($arr_history, 1); 
    $selected = $arr_history[$key]; 
    unset($arr_history[$key]); 
    echo $selected . PHP_EOL; 
} 

?>