简单PHP随机化器

Posted

tags:

篇首语:本文由小常识网(cha138.com)小编为大家整理,主要介绍了简单PHP随机化器相关的知识,希望对你有一定的参考价值。

Visit the link for instructions on how to use it.
  1. <?php
  2. /*
  3. Simple randomizer.
  4. Roger Johansson, http://www.456bereastreet.com/
  5. */
  6. echo '<ul>' . " ";
  7. $items = array(
  8. 1 => array(
  9. 'href' => 'url-1',
  10. 'title' => 'title-text-1',
  11. 'src' => 'image-1.jpg',
  12. 'alt' => 'alt-text-1'
  13. ),
  14. 2 => array(
  15. 'href' => 'url-2',
  16. 'title' => 'title-text-2',
  17. 'src' => 'image-2.jpg',
  18. 'alt' => 'alt-text-2'
  19. ),
  20. 3 => array(
  21. 'href' => 'url-3',
  22. 'title' => 'title-text-3',
  23. 'src' => 'image-3.jpg',
  24. 'alt' => 'alt-text-3'
  25. ),
  26. 4 => array(
  27. 'href' => 'url-4',
  28. 'title' => 'title-text-4',
  29. 'src' => 'image-4.jpg',
  30. 'alt' => 'alt-text-4'
  31. ),
  32. 5 => array(
  33. 'href' => 'url-5',
  34. 'title' => 'title-text-5',
  35. 'src' => 'image-5.jpg',
  36. 'alt' => 'alt-text-5'
  37. )
  38. );
  39. $numberOfItems = 3; // Change to the number of items you want
  40. $randItems = array_rand($arrItems, $numberOfItems);
  41. for ($i = 0; $i < $numberOfItems; $i++) {
  42. $item = $arrItems[$randItems[$i]];
  43. echo " " . '<li class="r' . ($i + 1) . '"><a href="' . $item['href'] . '" title="' . $item['title'] . '"><img src="' . $item['src'] . '" alt="' . $item['alt'] . '"></a></li>' . " ";
  44. }
  45. echo '</ul>' . " ";
  46. ?>

以上是关于简单PHP随机化器的主要内容,如果未能解决你的问题,请参考以下文章

java 片段实例化器

php 随机WordPress片段

PHP 代码片段

python Maya关键帧随机化器

21个常用代码片段

第一个问题! NPC 步行循环随机化器按预期工作(边界确实需要调整),但不播放嵌套的步行动画? (AS3)