Php 随机选择已定义变量的集合

Php 随机选择已定义变量的集合,php,arrays,multidimensional-array,Php,Arrays,Multidimensional Array,我正努力做到以下几点: 定义多组变量 使用PHP随机选择一个集合 在整个页面中从所选集合回显数据 下面是带有虚拟变量和数据的逻辑示例: ---定义每个集合--- SET 1 { title1 = Sample School text1 = School is great link1 = school-page.php } SET 2 { title2 = Sample Business text2 = Business is great link2 = biz-page.php } SET

我正努力做到以下几点:

  • 定义多组变量
  • 使用PHP随机选择一个集合
  • 在整个页面中从所选集合回显数据
  • 下面是带有虚拟变量和数据的逻辑示例:

    ---定义每个集合---

    SET 1 {
    title1 = Sample School
    text1 = School is great
    link1 = school-page.php
    }
    
    SET 2 {
    title2 = Sample Business
    text2 = Business is great
    link2 = biz-page.php
    }
    
    SET 3 {
    title3 = Sample Organization
    text2 = Organization is great
    link3 = org-page.php
    }
    
    <h1><?php echo $title(from selected set) ?></h2>
    <p><?php echo $text(from selected set) ?></p>
    <div>Visit page <a href="<?php echo $link(from selected set) ?>">here</a></div>
    
    ——页面内所选集合的输出变量---

    SET 1 {
    title1 = Sample School
    text1 = School is great
    link1 = school-page.php
    }
    
    SET 2 {
    title2 = Sample Business
    text2 = Business is great
    link2 = biz-page.php
    }
    
    SET 3 {
    title3 = Sample Organization
    text2 = Organization is great
    link3 = org-page.php
    }
    
    <h1><?php echo $title(from selected set) ?></h2>
    <p><?php echo $text(from selected set) ?></p>
    <div>Visit page <a href="<?php echo $link(from selected set) ?>">here</a></div>
    
    
    

    访问页面