บทความ > PHP

PHP random arrays Turn Back

เมื่อ 2016-09-09 17:00:27

PHP Script for random one of array key

<?PHP

$text = array();
$text[] = 'Content 1';
$text[] = 'Content 2';
$text[] = 'Content 3';

echo $text[ array_rand($text,1) ];

?>

If you want more than one

<?PHP

$keys = array_rand($text, 2);

echo $text[ $keys[0] ];
echo $text[ $keys[1] ];

?>

Turn Back

Automotive ดูทั้งหมด

IT Update ดูทั้งหมด