当前位置: 首页>>代码示例>>PHP>>正文


PHP shuffle_assoc函数代码示例

本文整理汇总了PHP中shuffle_assoc函数的典型用法代码示例。如果您正苦于以下问题:PHP shuffle_assoc函数的具体用法?PHP shuffle_assoc怎么用?PHP shuffle_assoc使用的例子?那么恭喜您, 这里精选的函数代码示例或许可以为您提供帮助。


在下文中一共展示了shuffle_assoc函数的15个代码示例,这些例子默认根据受欢迎程度排序。您可以为喜欢或者感觉有用的代码点赞,您的评价将有助于系统推荐出更棒的PHP代码示例。

示例1: show_question

function show_question($question, $alternative, $image)
{
    //steg 1: komplettera denna funktion så att den visar ett formulär med en fråga
    shuffle_assoc($alternative);
    foreach ($alternative as $onevalue => $onealternative) {
        //lägg till kod för radiobuttons här
    }
}
开发者ID:Tibbelit,项目名称:mah-webb.github.io,代码行数:8,代码来源:functions.php

示例2: vwm_checkboxes_preprocess

/**
 * Preprocess checkbox options
 *
 * @param array				Checkbox options
 * @return array			Checkbox options
 */
function vwm_checkboxes_preprocess($options)
{
    // If the options are to be displayed randomally
    if ($options['order'] == 'random') {
        $options['checkboxes'] = shuffle_assoc($options['checkboxes']);
    }
    return $options;
}
开发者ID:valentinico,项目名称:eecore29q,代码行数:14,代码来源:vwm_checkboxes_helper.php

示例3: vwm_radio_matrix_preprocess

/**
 * Preprocess radio matrix options
 *
 * @param array				Radio matrix options
 * @return array			Radio matrix options
 */
function vwm_radio_matrix_preprocess($options)
{
    // If the x options are to be displayed randomally
    if ($options['x_order'] === 'random') {
        $options['x'] = shuffle_assoc($options['x']);
    }
    // If the y options are to be displayed randomally
    if ($options['y_order'] === 'random') {
        $options['y'] = shuffle_assoc($options['y']);
    }
    return $options;
}
开发者ID:valentinico,项目名称:eecore29q,代码行数:18,代码来源:vwm_radio_matrix_helper.php

示例4: testShuffleAssoc

 public function testShuffleAssoc()
 {
     $this->assertEquals('string', shuffle_assoc('string'));
     $expected = ['x' => 'x', 'y' => 'y', 'z' => 'z'];
     $shuffled = shuffle_assoc($expected);
     $this->assertFalse((bool) array_diff_assoc($expected, $shuffled));
     $this->assertFalse((bool) array_diff_assoc($shuffled, $expected));
     srand(40);
     $expected = ['z' => 'z', 'y' => 'y', 'x' => 'x'];
     $shuffled = shuffle_assoc($expected);
     $this->assertEquals(json_encode($expected), json_encode($shuffled));
 }
开发者ID:PaulAntunes,项目名称:gclf-paul,代码行数:12,代码来源:GlobalFunctionsTest.php

示例5: createDeck

function createDeck()
{
    $suits = array("clubs", "diamonds", "hearts", "spades");
    $faces = array("Ace" => 1, "2" => 2, "3" => 3, "4" => 4, "5" => 5, "6" => 6, "7" => 7, "8" => 8, "9" => 9, "10" => 10, "Jack" => 10, "Queen" => 10, "King" => 10);
    $deck = array();
    foreach ($faces as $key => $face) {
        foreach ($suits as $suit) {
            $newKey = "{$key} of {$suit}";
            $deck[$newKey] = $face;
        }
    }
    shuffle_assoc($deck);
    return $deck;
}
开发者ID:jacobfoard,项目名称:challenges,代码行数:14,代码来源:4_insane.php

示例6: sizeof

	$t = Title::makeTitle($row->page_namespace, $row->page_title);
	if (!$t) continue;
	$titles[] = $t;
}
*/
#echo sizeof($titles); exit;
$index = 0;
$old = wfTimestamp(TS_MW, time() - 60 * 60);
foreach ($titles as $t) {
    $recentedits = $dbr->selectField('recentchanges', array('count(*)'), array('rc_cur_id' => $t->getArticleID(), 'rc_user_text' => $username, "rc_timestamp > '{$old}'"));
    if ($recentedits > 0) {
        echo "{$t->getText()} was recently edited, skipping.\n";
        continue;
    }
    $r = Revision::newFromTitle($t);
    $kw = shuffle_assoc($kw);
    if (!$r) {
        continue;
    }
    $text = $r->getText();
    $parts = preg_split("@(\\[\\[[^\\]]*\\]\\]|\\{\\{[^\\}]*\\}\\}|\\[[^\\]]*])@", $text, -1, PREG_SPLIT_DELIM_CAPTURE | PREG_SPLIT_NO_EMPTY);
    $changed = false;
    $onthispage = 0;
    $newtext = $text;
    $thisround = array();
    foreach ($parts as $p) {
        $newp = $p;
        foreach ($kw as $w => $dest) {
            if (isset($thisround[$w])) {
                break;
            }
开发者ID:biribogos,项目名称:wikihow-src,代码行数:31,代码来源:sprinkle_links.php

示例7: shuffle_assoc

require 'class.roundrobin.php';
function shuffle_assoc(&$array)
{
    $keys = array_keys($array);
    shuffle($keys);
    foreach ($keys as $key) {
        $new[$key] = $array[$key];
    }
    $array = $new;
    echo 'shuffle_assoc<pre>', print_r($array, true), '</pre><br>';
    return true;
}
// Let's see how 7 of the best british football teams fight against each other
$teams = array('Banbury United', 'Bashley', 'Bedford Town', 'Brackley Town', 'Cambridge City', 'Chippenham Town', 'Clevedon Town');
shuffle_assoc($teams);
$roundrobin = new roundrobin($teams);
// Generated matches with matchdays and free tickets - because we have an uneven number of teams
echo "<h3>Generated matches with matchdays and free tickets</h3><br />";
$roundrobin->free_ticket_identifer = "FREE TICKET";
//default is "free ticket"
$roundrobin->create_matches();
// Did everything went right?
if ($roundrobin->finished) {
    $i = 1;
    //Ok, iterating over the matchdays...
    while ($roundrobin->next_matchday()) {
        echo "-------Matchday " . $i . "-------<br />";
        //...and the matches of one match day
        while ($match = $roundrobin->next_match()) {
            echo $match[0] . "  <b>vs</b>  " . $match[1] . "<br />";
开发者ID:santas156,项目名称:joomleague-2-komplettpaket,代码行数:30,代码来源:example_full.php

示例8: array_keys

    if (!is_array($list)) {
        return $list;
    }
    $keys = array_keys($list);
    shuffle($keys);
    $random = array();
    foreach ($keys as $key) {
        $random[$key] = $list[$key];
    }
    return $random;
}
$randomtrailObj = new trails();
$randomtrails = $randomtrailObj->getRand();
$count = $randomtrails['totalMatched'];
$trails = $randomtrails['trails'];
$trails = shuffle_assoc($trails);
$ids = array_keys($trails);
$trails_master = $trails;
$trails = array_slice($trails_master, 0, 12);
$trails_next = array_slice($trails_master, 12, 6);
$trails_last = array_slice($trails_master, 18, 6);
ob_start();
?>
<!DOCTYPE html>
<html lang="en">
<head>
  <meta http-equiv="Content-Type" content="text/html; charset=UTF-8"/>
  <meta name="viewport" content="width=device-width, initial-scale=1, maximum-scale=1.0"/>
  <title>Prescription Trails - New Mexico</title>
    <meta name="description" content="The New Mexico Prescription Trails web site will help you find some of the best park and trail walking and wheelchair rolling paths in the state!" />
    <!-- Schema.org markup for Google+ -->
开发者ID:jmayfiel,项目名称:prescriptiontrails,代码行数:31,代码来源:index.php

示例9: get_record

    } else {
        $idnext = 0;
    }
    $data = get_record("apps_dragdrope", array("id" => $idc));
    $score = get_user_score($_SESSION['userid'], 8);
    $c = 0;
    $questions = array();
    for ($i = 1; $i <= 5; $i++) {
        $var = "var" . $i;
        if (!empty($data->{$var})) {
            $questions[$i] = $data->{$var};
        }
    }
    $questions = shuffle_assoc($questions);
    $answers = array();
    for ($i = 1; $i <= 5; $i++) {
        $var = "a" . $i;
        if (!empty($data->{$var})) {
            $answers[$i] = $data->{$var};
        }
    }
    $answers = shuffle_assoc($answers);
    if (isset($_SESSION['currentcourse'])) {
        $course = get_record("course", array("id" => $_SESSION['currentcourse']));
    } else {
        $course = get_record("course", array("id" => $_COOKIE['mcm_course']));
    }
    add_log($_SESSION['userid'], 8, time());
    mobilehtmlheader('DragDrope activity');
    include_once $CFG['dirroot'] . "/apps/dragdrope/" . $appsfolder . "/i.php";
}
开发者ID:e-rasvet,项目名称:mcm,代码行数:31,代码来源:index.php

示例10: getCategoryExerciseTree

 /**
  * @param Exercise $exercise
  * @param int $course_id
  * @param string $order
  * @param bool $shuffle
  * @param bool $excludeCategoryWithNoQuestions
  * @return array|bool
  */
 public function getCategoryExerciseTree($exercise, $course_id, $order = null, $shuffle = false, $excludeCategoryWithNoQuestions = true)
 {
     if (empty($exercise)) {
         return array();
     }
     if (!$exercise->specialCategoryOrders) {
         return false;
     }
     $course_id = intval($course_id);
     $table = Database::get_course_table(TABLE_QUIZ_REL_CATEGORY);
     $categoryTable = Database::get_course_table(TABLE_QUIZ_QUESTION_CATEGORY);
     $sql = "SELECT * FROM {$table} qc\n              \tLEFT JOIN {$categoryTable} c\n                ON (qc.c_id = c.c_id AND c.id = qc.category_id)\n                WHERE qc.c_id = {$course_id} AND exercise_id = {$exercise->id} ";
     if (!empty($order)) {
         $sql .= "ORDER BY {$order}";
     }
     $categories = array();
     $result = Database::query($sql);
     if (Database::num_rows($result)) {
         while ($row = Database::fetch_array($result, 'ASSOC')) {
             if ($excludeCategoryWithNoQuestions) {
                 if ($row['count_questions'] == 0) {
                     continue;
                 }
             }
             if (empty($row['title']) && empty($row['category_id'])) {
                 $row['title'] = get_lang('NoCategory');
             }
             $categories[$row['category_id']] = $row;
         }
     }
     if ($shuffle) {
         shuffle_assoc($categories);
     }
     return $categories;
 }
开发者ID:jloguercio,项目名称:chamilo-lms,代码行数:43,代码来源:TestCategory.php

示例11: mysql_query

 $result2 = mysql_query("SELECT ID, examen_ID, user_ID, time, pregunta, respuestas, tiempo\r\nFROM " . SQL . "examenes_preg\r\nWHERE examen_ID = '" . $_GET['b'] . "' OR examen_ID = 0\r\nORDER BY examen_ID DESC, RAND() LIMIT " . $r['num_preguntas'], $link);
 echo mysql_error($link);
 while ($r2 = mysql_fetch_array($result2)) {
     $respuestas = '';
     $res2 = '';
     $res = explode("|", $r2['respuestas']);
     $res2['a'] = $res[0];
     $respuestas_correctas[] = md5($res[0]);
     $res2['b'] = $res[1];
     if ($res[2]) {
         $res2['c'] = $res[2];
     }
     if ($res[3]) {
         $res2['d'] = $res[3];
     }
     $res2 = shuffle_assoc($res2);
     $examen_tiempo += $r2['tiempo'];
     foreach ($res2 as $ID => $respuesta) {
         $respuestas .= '<input type="radio" name="respuesta' . $r2['ID'] . '" value="' . md5($respuesta) . '" />' . $respuesta . '<br />';
     }
     if ($pregs) {
         $pregs .= '|';
     }
     $pregs .= $r2['ID'];
     $txt .= '<li><b>&iquest;' . $r2['pregunta'] . '?</b><br />' . $respuestas . '</li>';
 }
 $examen_tiempo += 10;
 $limite_tiempo = time() + $examen_tiempo;
 $_SESSION['examen']['respuestas'] = $respuestas_correctas;
 $_SESSION['examen']['tiempo'] = $limite_tiempo;
 $_SESSION['examen']['ID'] = $_GET['b'];
开发者ID:rafacouto,项目名称:VirtualPol,代码行数:31,代码来源:c-examenes.php

示例12: shuffle

shuffle($result);
$body = '';
for ($ex = 0; $ex < TOTAL_EXAMENES_A_GENERAR; $ex++) {
    $num_pregunta = 1;
    $referencia_examen = mb_strtoupper(get_random_string(4, 4, true, false, false));
    if ($ex > 0) {
        $body .= '<div class="newpage"></div>' . PHP_EOL;
    }
    $body .= '<p>Nombre: <span class="referenciaexamen"> COD: ' . $referencia_examen . '</span></p>';
    $soluciones[$referencia_examen] = array();
    foreach ($result as $a => $b) {
        $body .= '<div id="pregunta' . $num_pregunta . '" class="pregunta">';
        $body .= '<h2 class="titulopregunta">' . $num_pregunta . ') ' . $b['titulo'] . '</h2>' . PHP_EOL;
        if ($b['tipo'] == 'TEST') {
            $body .= '<ul class="listarespuestastest">' . PHP_EOL;
            $respuestas_rnd = shuffle_assoc($b['respuestas']);
            $i = 'a';
            foreach ($respuestas_rnd as $c => $d) {
                $body .= '<li class="resupestatest">' . $i . ') ' . $c . '</li>' . PHP_EOL;
                if ($d) {
                    $soluciones[$referencia_examen][$num_pregunta] = $i;
                }
                $i++;
            }
            $body .= '</ul>' . PHP_EOL;
        } elseif ($b['tipo'] == 'DEFINE') {
            $body .= str_repeat("<br />", $b['espacios']);
        }
        $body .= '</div>' . PHP_EOL;
        if ($num_pregunta % PREGUNTAS_POR_PAGINA == 0) {
            $body .= '<div class="newpage"></div>' . PHP_EOL;
开发者ID:josepgarcia,项目名称:generadorexamenes,代码行数:31,代码来源:index.php

示例13: show_japanese

function show_japanese()
{
    // try-catchで接続エラーを取得&表示
    try {
        $pdo_object = new PDO('mysql:host=localhost;dbname=Challenge_db;charset=utf8', 'sakamoto', 2591);
    } catch (PDOException $E) {
        die('接続に失敗しました:' . $E->getMessage());
    }
    //SQL文を格納した文字列を定義(今回はレコード指定のSQL文)
    $sql = "select * from movies where movie_type=2";
    //実行とその結果を受け取れる変数を用意
    $query = $pdo_object->prepare($sql);
    //SQLを実行
    $query->execute();
    $youga_query = $query->fetchAll(PDO::FETCH_ASSOC);
    //var_dump($youga_query);
    //配列データをシャッフルさせる
    $result = shuffle_assoc($youga_query);
    $i = 0;
    $view = 3;
    foreach ($result as $value) {
        if ($i >= $view) {
            break;
        } else {
            ?>
  <article>
    <a href="<?php 
            echo $value["FilmUrl"];
            ?>
" target="window"> <img src="<?php 
            echo $value["ImageUrl"];
            ?>
" width="300" height="363"></a>
    <a href="<?php 
            echo $value["FilmUrl"];
            ?>
" target="window"><h2><?php 
            echo $value["FilmTitle"];
            ?>
</h2></a>


  <form action="<?php 
            echo MOVIE_DETAIL;
            ?>
?id=<?php 
            echo $value['FilmID'];
            ?>
" method="POST">
    <input type="hidden" name="FilmTitle" value="<?php 
            echo $value['FilmTitle'];
            ?>
";>
    <input type="hidden" name=" itemCaption" value="<?php 
            echo $value['itemCaption'];
            ?>
";>
    <input type="submit" name="detail" value="作品詳細";>
  </form>

  </article>
  <?php 
            $i++;
        }
    }
    //接続を切断
    $pdo_object = null;
}
开发者ID:Taka-Haru,项目名称:Highly_rated_movies,代码行数:68,代码来源:show_japanese.php

示例14: shuffle_assoc

    }
}
/* */
function shuffle_assoc(&$array)
{
    $keys = array_keys($array);
    shuffle($keys);
    foreach ($keys as $key) {
        $new[$key] = $array[$key];
    }
    $array = $new;
    return true;
}
if (isset($_POST['q']) && isset($_POST['maxResults'])) {
    $result = array_merge($videos, $images, $tweetsres);
    shuffle_assoc($result);
    $result = array_slice($result, 0, $_POST['maxResults']);
    $htmlres = '';
    //var_dump($result);
    foreach ($result as $key => $value) {
        $htmlres .= $value;
    }
    $htmlBody .= '<ul>' . $htmlres . '</ul>';
}
?>

<!doctype html>
<html>
  <head>
    <meta charset="utf-8">
    <title>SearchAll</title>
开发者ID:spark942,项目名称:supinternet-projects,代码行数:31,代码来源:index.php

示例15: get_baner

function get_baner($W, $H)
{
    global $theme_baners, $all_baners, $used_baners, $script_fname, $ftp_con, $ftp_dir, $tmp;
    global $script_dir, $scripts, $keyword, $randkeyword;
    shuffle_assoc($theme_baners);
    shuffle_assoc($all_baners);
    $key = $W . '_' . $H;
    if (array_key_exists($key, $theme_baners)) {
        $baners = $theme_baners[$key];
        $new_baners = array_diff($baners, $used_baners);
        $new_baners = array_values(array_unique($new_baners));
        shuffle($new_baners);
        if (count($new_baners) > 0) {
            $baner = $new_baners[array_rand($new_baners)];
        } else {
            $baner = $baners[array_rand($baners)];
        }
        unset($baners);
    } else {
        foreach ($theme_baners as $curr_key => $curr_val) {
            $curr_size_arr = explode('_', $curr_key);
            $curr_W = $curr_size_arr['0'];
            if (isset($curr_size_arr['1'])) {
                $curr_H = $curr_size_arr['1'];
            } else {
                echo 'Неправильный формат ключа банера';
                continue;
            }
            if ($curr_W <= $W && $curr_H <= $H) {
                $kandidats[] = $curr_val;
            }
        }
        if (isset($kandidats)) {
            $kandidats = array_diff($kandidats, $used_baners);
            $kandidats = array_values(array_unique($kandidats));
            shuffle($kandidats);
            $baners = $kandidats[array_rand($kandidats)];
            shuffle($baners);
            unset($kandidats);
            $baner = $baners[array_rand($baners)];
            unset($baners);
        } elseif (array_key_exists($key, $all_baners)) {
            $baners = $all_baners[$key];
            $new_baners = array_diff($baners, $used_baners);
            $baners = array_unique($baners);
            shuffle($baners);
            $baner = $baners[array_rand($baners)];
            unset($baners);
            //$baner = str_replace('[SCRIPTNAME]',$b_script_fname,$baner);
            $baner = str_replace('[ANKOR]', $keyword, $baner);
            $baner = str_replace('[RANDKEYWORD]', $randkeyword, $baner);
            return $baner;
            exit;
        } else {
            foreach ($all_baners as $curr_key => $curr_val) {
                $curr_size_arr = explode('_', $curr_key);
                $curr_W = $curr_size_arr['0'];
                $curr_H = $curr_size_arr['1'];
                if ($curr_W <= $W && $curr_H <= $H) {
                    $kandidats[] = $curr_val;
                }
            }
            if (isset($kandidats)) {
                $kandidats = array_diff($kandidats, $used_baners);
                $kandidats = array_values(array_unique($kandidats));
                shuffle($kandidats);
                $baners = $kandidats[array_rand($kandidats)];
                $baners = array_values(array_unique($baners));
                unset($kandidats);
                shuffle($baners);
                $baner = $baners[array_rand($baners)];
                unset($baners);
            } else {
                $baner = '';
            }
        }
    }
    if (!$baner == '') {
        $used_baners[] = $baner;
    }
    $baner_str_arr = explode('|||', $baner);
    if (count($baner_str_arr) > 1) {
        $id_redir = $baner_str_arr[0];
        $baner = $baner_str_arr[1];
    } else {
        $baner = $baner_str_arr[0];
    }
    if (isset($id_redir)) {
        //Получаем редирект
        $result = mysql_query("SELECT `redir_code` FROM `redirects` WHERE `id` = '{$id_redir}'");
        if (!$result) {
            echo mysql_error();
            set_status('dorgen_tasks', $id_task, 'dor_status', 'error');
            exit;
        }
        while ($row = mysql_fetch_array($result, MYSQL_ASSOC)) {
            $redir_code = StripSlashes($row["redir_code"]);
        }
        mysql_free_result($result);
        //Имя файла со скриптом редиректа текущего банера
//.........这里部分代码省略.........
开发者ID:ivrm,项目名称:mbgdorgen,代码行数:101,代码来源:function.php


注:本文中的shuffle_assoc函数示例由纯净天空整理自Github/MSDocs等开源代码及文档管理平台,相关代码片段筛选自各路编程大神贡献的开源项目,源码版权归原作者所有,传播和使用请参考对应项目的License;未经允许,请勿转载。