Return to Snippet

Revision: 11193
at January 27, 2009 17:25 by gfazioli


Initial Code
<ul>
<?php
// LI items
$a = array(
		   "<li>Elemento 1</li>",
		   "<li>Elemento 2</li>",
		   "<li>Elemento 3</li>",
		   "<li>Elemento 4</li>",
		   "<li>Elemento 5</li>",
		   "<li>Elemento 6</li>",
		   "<li>Elemento 7</li>",
		   "<li>Elemento 8</li>",
		   "<li>Elemento 9</li>"
		  );
shuffle( $a );
$na = array_slice( $a, 0, 4 );
echo implode('', $na );
?>
</ul>

Initial URL
http://www.undolog.com/2009/01/27/very-short-trick-prendere-elementi-casuali-da-un-array-in-php/

Initial Description

                                

Initial Title
Get random item array in PHP

Initial Tags
php

Initial Language
PHP