Good afternoon friends help with the question:
I want to output the answer randomly from an array, but output its index, and not the value?
$ans = array ( 1 => 'да', 2 => 'нет', 3 => 'никогда', 4 => 'очень скоро', 5 => 'забудь', 6 => 'зачем тебе?' ); $vopros = 'Выучу ли я анgлийский'; $random = array_rand($ans); $otvet = $random; echo "Вопрос: {$vopros}<br/>"; echo "ответ: {$otvet}<br/>";
The answer is:
Q: Will I learn English?
Answer: 1
$ans[$random]
? - Alexey Shimansky