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


PHP shuffle函数代码示例

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


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

示例1: generate_cookie

 public function generate_cookie()
 {
     $characters = 'a,b,c,d,e,f,g,h,i,j,k,l,m,n,o,p,,q,r,s,t,u,v,w,x,y,z,1,2,3,4,5,6,7,8,9,0';
     $characters_array = explode(',', $characters);
     shuffle($characters_array);
     return implode('', $characters_array);
 }
开发者ID:jhernani,项目名称:chu,代码行数:7,代码来源:E_security.php

示例2: executeNormalView

 public function executeNormalView()
 {
     $this->setup();
     $this->options['constraints'] = $this->getOption('constraints', array());
     // Behave well if it's not set yet!
     if (strlen($this->slot->value)) {
         $items = $this->slot->MediaItems;
         $data = $this->slot->getArrayValue();
         $order = $data['order'];
         $itemsById = aArray::listToHashById($items);
         $this->items = array();
         foreach ($order as $id) {
             if (isset($itemsById[$id])) {
                 $this->items[] = $itemsById[$id];
             }
         }
         $this->itemIds = aArray::getIds($this->items);
         foreach ($this->items as $item) {
             $this->itemIds[] = $item->id;
         }
         if ($this->getOption('random', false)) {
             shuffle($this->items);
         }
     } else {
         $this->items = array();
         $this->itemIds = array();
     }
 }
开发者ID:verenate,项目名称:gri,代码行数:28,代码来源:BaseaSlideshowSlotComponents.class.php

示例3: Render

  function Render()
  {
    global $currentUser;
    if (!$currentUser)
      return;

    if (!$currentUser->CanSubmitItems())
      return;

    echo "\n\n";
    echo "<div class='pouettbl' id='".$this->uniqueID."'>\n";

    echo "  <h2>".$this->title."</h2>\n";
    echo "  <div class='content'>\n";

    $width = 15;

    $g = glob(POUET_CONTENT_LOCAL."avatars/*.gif");
    shuffle($g);
    $g = array_slice($g,0,$width * $width);

    echo "<ul id='avatargallery'>\n";
    foreach($g as $v)
      printf("  <li><img src='".POUET_CONTENT_URL."avatars/%s' alt='%s' title='%s'/></li>\n",basename($v),basename($v),basename($v));
    echo "</ul>\n";

    echo "  </div>\n";
    echo "</div>\n";
  }
开发者ID:neodyme60,项目名称:pouet2.0,代码行数:29,代码来源:submit_avatar.php

示例4: getBanners

 protected function getBanners()
 {
     // images at {theme_path}/bnr
     $base_url = Yii::app()->theme->baseUrl;
     // 150x40
     $banners[] = array('link' => 'http://www.adyra.com', 'image' => $base_url . '/bnr/adyra.png');
     //$banners[] = array('link' => 'http://www.grupomoyvesa.com', 'image' => $base_url.'/bnr/moyvesa.png');
     //$banners[] = array('link' => 'http://www.melicar.com', 'image' => $base_url.'/bnr/melicar.png');
     //$banners[] = array('link' => 'http://www.fiateira.com', 'image' => $base_url.'/bnr/fiateira.png');
     $banners[] = array('link' => 'http://www.llantaslandin.com', 'image' => $base_url . '/bnr/landin.png');
     $banners[] = array('link' => 'http://www.grupotrigocar.com', 'image' => $base_url . '/bnr/trigocar.png');
     $banners[] = array('link' => 'http://www.imgautosubastas.com', 'image' => $base_url . '/bnr/imgautosubastas.png');
     $banners[] = array('link' => 'http://www.autosrema.com', 'image' => $base_url . '/bnr/rema.png');
     $banners[] = array('link' => 'http://www.automovilesmlosada.com', 'image' => $base_url . '/bnr/losada.png');
     $banners[] = array('link' => 'http://www.carballeiraautomocion.com', 'image' => $base_url . '/bnr/carballeira.png');
     $banners[] = array('link' => '#', 'image' => $base_url . '/bnr/monterey.png');
     $banners[] = array('link' => '#', 'image' => $base_url . '/bnr/mediodia.png');
     $banners[] = array('link' => 'http://www.donsilencioso.com', 'image' => $base_url . '/bnr/donsilencioso.png');
     $banners[] = array('link' => 'http://www.hangar.es', 'image' => $base_url . '/bnr/hangar.png');
     $banners[] = array('link' => 'http://rysservicios.com/', 'image' => $base_url . '/bnr/rys.png');
     // talleresmonterrey
     // talleresmediodia
     // donsilencioso
     shuffle($banners);
     return $banners;
 }
开发者ID:CHILMEX,项目名称:amocasion,代码行数:26,代码来源:Banners.php

示例5: generarPalabras

function generarPalabras(&$palabraelegida, &$coincidencias, $palabras)
{
    global $VOCALES, $NUM_PALABRAS;
    shuffle($palabras);
    $palabrasrestantes = $palabras;
    $palabraelegida = [$palabras[0]];
    unset($palabrasrestantes[0]);
    $palabraconsonantes = str_replace($VOCALES, "", $palabraelegida[0]);
    $coincidencias = [];
    while (count($palabraelegida) < $NUM_PALABRAS) {
        $found = false;
        for ($i = 0; $i < strlen($palabraconsonantes) && !$found; $i++) {
            $c = $palabraconsonantes[$i];
            foreach ($palabrasrestantes as $key => $value) {
                if (strpos($value, $c) !== false) {
                    array_push($palabraelegida, $value);
                    $palabraconsonantes = str_replace($c, "", str_replace($VOCALES, "", $value));
                    array_push($coincidencias, $c);
                    unset($palabrasrestantes[$key]);
                    $found = true;
                    break;
                }
            }
        }
        //si no encuentra $found==false volver a empezar
        if ($found == false) {
            shuffle($palabras);
            $palabrasrestantes = $palabras;
            $palabraelegida = [$palabras[0]];
            unset($palabrasrestantes[0]);
            $palabraconsonantes = str_replace($VOCALES, "", $palabraelegida[0]);
            $coincidencias = [];
        }
    }
}
开发者ID:villapilla,项目名称:PHP,代码行数:35,代码来源:tabla.php

示例6: compo_cloud

function compo_cloud()
{
    global $wpdb;
    $topurl = get_bloginfo("url");
    $start = 10;
    $total = 24;
    $query = "SELECT {$wpdb->terms}.term_id, {$wpdb->terms}.name, {$wpdb->term_taxonomy}.count, {$wpdb->terms}.slug FROM (({$wpdb->term_relationships} INNER JOIN {$wpdb->posts} ON {$wpdb->term_relationships}.object_id = {$wpdb->posts}.ID) INNER JOIN {$wpdb->term_taxonomy} ON {$wpdb->term_relationships}.term_taxonomy_id = {$wpdb->term_taxonomy}.term_taxonomy_id) INNER JOIN {$wpdb->terms} ON {$wpdb->term_taxonomy}.term_id = {$wpdb->terms}.term_id WHERE ((({$wpdb->term_taxonomy}.taxonomy)='post_tag') AND (({$wpdb->posts}.post_status)='publish')) GROUP BY {$wpdb->terms}.name ORDER BY count DESC, {$wpdb->terms}.name";
    # LIMIT $start,$total";
    $terms = $wpdb->get_results($query);
    shuffle($terms);
    $data = array();
    foreach ($terms as $e) {
        if ($e->count < 2) {
            continue;
        }
        $data[] = "{$e->count}|{$e->name}|{$e->slug}";
        if (count($data) >= $total) {
            break;
        }
    }
    natcasesort($data);
    $out = array();
    $n = 0;
    foreach ($data as $v) {
        $z = intval(8 + $n * 0.5);
        list($x, $name, $slug) = explode("|", $v);
        //         $name = htmlentities($name);
        $out[] = "<a href='{$topurl}/tag/{$slug}' style='font-size:{$z}px'>{$name}</a>";
        $n += 1;
    }
    shuffle($out);
    echo implode(" ", $out);
}
开发者ID:philhassey,项目名称:ludumdare,代码行数:33,代码来源:cloud.php

示例7: make_answer_form

 protected function make_answer_form($attempt = null)
 {
     global $USER, $CFG;
     // don't shuffle answers (could be an option??)
     $getanswers = array_slice($this->get_answers(), 2);
     $answers = array();
     foreach ($getanswers as $getanswer) {
         $answers[$getanswer->id] = $getanswer;
     }
     $responses = array();
     foreach ($answers as $answer) {
         // get all the response
         if ($answer->response != null) {
             $responses[] = trim($answer->response);
         }
     }
     $responseoptions = array('' => get_string('choosedots'));
     if (!empty($responses)) {
         shuffle($responses);
         foreach ($responses as $response) {
             $responseoptions[htmlspecialchars($response)] = $response;
         }
     }
     if (isset($USER->modattempts[$this->lesson->id]) && !empty($attempt->useranswer)) {
         $useranswers = explode(',', $attempt->useranswer);
         $t = 0;
     } else {
         $useranswers = array();
     }
     $action = $CFG->wwwroot . '/mod/lesson/continue.php';
     $params = array('answers' => $answers, 'useranswers' => $useranswers, 'responseoptions' => $responseoptions, 'lessonid' => $this->lesson->id, 'contents' => $this->get_contents());
     $mform = new lesson_display_answer_form_matching($action, $params);
     return $mform;
 }
开发者ID:MoodleMetaData,项目名称:MoodleMetaData,代码行数:34,代码来源:matching.php

示例8: runOften

 public static function runOften()
 {
     $feeds = XenForo_Model::create('DigitalPointSocialBar_Model_SocialBar')->getSlugsFromOptions();
     shuffle($feeds);
     // randomize order in case someone has absurd number of lists attached to forums (would need to be more than 180 unique) to work around Twitter API limits
     $cacheObject = XenForo_Application::getCache();
     $twitter = DigitalPointSocialBar_Helper_Twitter::getService(XenForo_Application::getOptions()->dpTwitterAccessToken, XenForo_Application::getOptions()->dpTwitterAccessTokenSecret, XenForo_Application::getOptions()->dpTwitterUsername);
     // forum specific feeds
     if ($feeds) {
         foreach ($feeds as $slug) {
             $tweets_array = array();
             $results = $twitter->listsStatuses(array('slug' => $slug, 'owner_screen_name' => XenForo_Application::getOptions()->dpTwitterUsername, 'count' => 250, 'include_rts' => 1, 'include_entities' => 1));
             if (count($results)) {
                 try {
                     for ($i = 0; $i < count($results); $i++) {
                         $tweet = $results[$i];
                         if (is_object($tweet->user)) {
                             $screen_name = $tweet->user->screen_name;
                             if (!@isset($tweets_array[$screen_name])) {
                                 $tweets_array[$screen_name] = DigitalPointSocialBar_Helper_Twitter::parseTweet($tweet);
                             }
                         }
                     }
                     $cacheObject->save(json_encode(array_values($tweets_array)), 'social_bar_' . str_replace('-', '_', $slug), array(), 604800);
                     // 7 day cache
                 } catch (Exception $e) {
                 }
             }
         }
     }
 }
开发者ID:Sywooch,项目名称:forums,代码行数:31,代码来源:SocialBar.php

示例9: getImagesFromFolder

 static function getImagesFromFolder(&$params)
 {
     if (!is_numeric($max = $params->get('max_images'))) {
         $max = 20;
     }
     $folder = $params->get('image_folder');
     if (!($dir = @opendir($folder))) {
         return null;
     }
     while (false !== ($file = readdir($dir))) {
         if (preg_match('/.+\\.(jpg|jpeg|gif|png)$/i', $file)) {
             // check with getimagesize() which attempts to return the image mime-type
             if (getimagesize(JPATH_ROOT . DS . $folder . DS . $file) !== FALSE) {
                 $files[] = $file;
             }
         }
     }
     closedir($dir);
     if ($params->get('sort_by')) {
         natcasesort($files);
     } else {
         shuffle($files);
     }
     $images = array_slice($files, 0, $max);
     $target = modDJImageSliderHelper::getSlideTarget($params->get('link'));
     foreach ($images as $image) {
         $slides[] = (object) array('title' => '', 'description' => '', 'image' => $folder . '/' . $image, 'link' => $params->get('link'), 'alt' => $image, 'target' => $target);
     }
     return $slides;
 }
开发者ID:arg2016,项目名称:innovacion,代码行数:30,代码来源:helper.php

示例10: tanya

 public function tanya()
 {
     header("Content-type: text/javascript");
     $teks = $this->input->get('txt');
     if ($teks == "'" or $teks == '"') {
         $teks = "Aku maho";
     } elseif ($teks == 1) {
         $teks = "Satu";
     } elseif ($teks == 2) {
         $teks = "Duaa";
     } elseif ($teks == 3) {
         $teks = "Tiga";
     } elseif ($teks == 0) {
         $teks = "Bantuan Urang!";
     } else {
         $teks = "Ferdhika ganteng";
     }
     $teks = strtolower($teks);
     if ($teks) {
         $hasil = $this->db->query("SELECT * FROM tb_about WHERE MATCH(no) AGAINST('" . $teks . "' IN BOOLEAN MODE);");
         if ($hasil->num_rows() > 0) {
             $cius = $hasil->result_array();
             shuffle($cius);
             $arr = array('no' => $teks, 'response' => $cius[0]['jawaban']);
         } else {
             $cius = array("Jangan masukin kata lain selain angka yang ada di list", "Salah euy!");
             shuffle($cius);
             $arr = array('no' => $teks, 'response' => $cius[0]);
         }
     } else {
         $arr = array('response' => 'masukin dek textnya');
     }
     echo json_encode($arr);
 }
开发者ID:ferdhika31,项目名称:curcol-code-igniter,代码行数:34,代码来源:tentang.php

示例11: generate

 public static function generate($length = 7)
 {
     $chars = array('1', '2', '3', '4', '5', '6', '7', '8', '9', '0', 'q', 'w', 'e', 'r', 't', 'y', 'u', 'i', 'o', 'p', 'a', 's', 'd', 'f', 'g', 'h', 'j', 'k', 'l', 'z', 'x', 'c', 'v', 'b', 'n', 'm', 'Q', 'W', 'E', 'R', 'T', 'Y', 'U', 'I', 'O', 'P', 'A', 'S', 'D', 'F', 'G', 'H', 'J', 'K', 'L', 'Z', 'X', 'C', 'V', 'B', 'N', 'M');
     shuffle($chars);
     $password = substr(implode('', $chars), 0, $length);
     return $password;
 }
开发者ID:nizsheanez,项目名称:documentation,代码行数:7,代码来源:PasswordGenerator.php

示例12: random

 /**
  * @brief 随机生成字符串函数
  * @param int $len 要生成的长度
  * @param string $type 生成字符串的类型
  * @return String 随机生成字符
  */
 public static function random($len = 6, $type = 'mix')
 {
     $len = intval($len);
     if ($len > 32) {
         $len = 32;
     }
     $str = '';
     $attr = array('a', 'b', 'c', 'd', 'e', 'f', 'g', 'h', 'i', 'j', 'k', 'l', 'm', 'n', 'o', 'p', 'q', 'r', 's', 't', 'u', 'v', 'w', 'x', 'y', 'z', 'g', 'm', 'p', 't', 'z', 'c');
     shuffle($attr);
     $int_attr = array('0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '0', '1', '2', '3', '4', '5', '6', '7', '8', '9', '5', '9');
     shuffle($int_attr);
     $attr = implode($attr);
     $int_attr = implode($int_attr);
     switch ($type) {
         case 'int':
             $str = $int_attr;
             break;
         case 'char':
             $str = $attr;
             break;
         default:
             $str = md5(uniqid(mt_rand(), true));
             break;
     }
     return substr($str, 0, $len);
 }
开发者ID:qinzhi,项目名称:fruiter,代码行数:32,代码来源:Hash.class.php

示例13: __construct

 public function __construct()
 {
     // Some logic to create the deck of cards
     $this->createDeck();
     // Shuffle the deck
     shuffle($this->cards);
 }
开发者ID:sameg14,项目名称:php-mastery-code,代码行数:7,代码来源:Deck.php

示例14: run

 /**
  * Runs the tests
  *
  * @return array $results
  *  Returns array of results. A result consists of 
  */
 function run()
 {
     $results = array();
     $this->saveState();
     $class = get_class($this);
     $class_methods = get_class_methods($class);
     shuffle($class_methods);
     // execute tests in random order!
     foreach ($class_methods as $cm) {
         if (substr($cm, -4) == 'Test') {
             // Run the test
             if (is_callable(array($this, 'setUp'))) {
                 $this->setUp();
             }
             //echo "running $class::$cm...\n";
             try {
                 $ret = call_user_func(array($this, $cm));
                 // $ret is not used for now.
                 $results[$class][$cm] = array(self::TEST_SUCCEEDED, 'succeeded');
             } catch (Pie_Exception_TestCase $e) {
                 // one of the predefined testcase outcomes occurred
                 $results[$class][$cm] = array($e->getCode(), $e->getMessage());
             } catch (Exception $e) {
                 $results[$class][$cm] = array(self::TEST_EXCEPTION, 'exception', $e);
             }
             if (is_callable(array($this, 'tearDown'))) {
                 $this->tearDown();
             }
             $this->restoreState();
         }
     }
     $this->hasToRun = false;
     return $results;
 }
开发者ID:EGreg,项目名称:PHP-On-Pie,代码行数:40,代码来源:TestCase.php

示例15: generateTagCloud

 private function generateTagCloud($tags, $resize = true, $min_font_size = 9, $max_font_size = 25, $font_weight)
 {
     if ($resize == true) {
         arsort($tags);
         $max_qty = max(array_values($tags));
         $min_qty = min(array_values($tags));
         $spread = $max_qty - $min_qty;
         if ($spread == 0) {
             $spread = 1;
         }
         $step = ((int) $max_font_size - (int) $min_font_size) / $spread;
         $cloud = array();
         foreach ($tags as $key => $value) {
             $size = rand((int) $min_font_size, (int) $max_font_size);
             $cloud[] = '<a href="' . $this->url->link('product/search', 'tag=' . $value) . '" style="text-decoration:none;font-size:' . $size . 'px;font-weight:' . $font_weight . ';" title="">' . $value . '</a> ';
         }
     } else {
         foreach ($tags as $key => $value) {
             $cloud[] = '<a href="' . $this->url->link('product/search', 'tag=' . $value) . '" style="text-decoration:none;" title="">' . $value . '</a> ';
         }
     }
     $tagcloud = '';
     shuffle($cloud);
     for ($x = 0; $x < count($cloud); $x++) {
         $tagcloud .= $cloud[$x];
     }
     return $tagcloud;
 }
开发者ID:rootcave,项目名称:9livesprints-web,代码行数:28,代码来源:boss_tagcloud.php


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