小编Wiz*_*ard的帖子

在数组中使用随机变量

首先,对不起,如果措辞不好,因为我是代码的初学者.

我目前正在从事在线计算机科学课程,但是我对如何做一小部分非常困惑.我们需要为此活动使用数组,其中用户有多个选择,每个不同的选择具有不同/唯一的文本输出.一切正常,除了我需要一个选择随机选择的选项,但是我对如何制作它有点困惑.您可以从我的代码中看到选项1-8.我希望它随机选择其中一个选项.

这是我的代码:

<?php
$train[0] = "Canada";
$train[1] = "Sahara Desert";
$train[2] = "Russia";
$train[3] = "Chernobyl";
$train[4] = "United States";
$train[5] = "North Korea";
$train[6] = "Germany";
$train[7] = "Hawaii";
?>

<!DOCTYPE html>
<html>
<head>
Took out everything here, it's not important.
</head>

    <body>
        <center>
    <h1>Vacation Time!</h1>

    <h4>You and your family just won the lottery! You all want to go on vacation, but nobody can agree where to go. Inside each train cart has a card with a location …
Run Code Online (Sandbox Code Playgroud)

html php arrays

5
推荐指数
1
解决办法
86
查看次数

标签 统计

arrays ×1

html ×1

php ×1