Horje
choose a random word from an array php Code Example
choose a random word from an array php
$items = array(1, 2, 3, 4, 5);
echo $items[array_rand($items)];
php get random element from array
<?php
//array_rand ( array $array [, int $num = 1 ] ) 
$input = array("Neo", "Morpheus", "Trinity", "Cypher", "Tank");
$rand_keys = array_rand($input, 2);
echo $input[$rand_keys[0]] . "\n";
echo $input[$rand_keys[1]] . "\n";
?>

Source: www.php.net
choose a random word from an array php
<?php
// array_rand() + shuffle
$answers = Array('Hello!','Salut!','Vivat!','Chao!','Привет');
shuffle($answers);
echo $answers[array_rand($answers)];

// I use it for BotMan:
$botman->hears('Hi', function ($bot) {
    $answers = Array('Hello!','Salut!','Vivat!','Chao!','Привет');
    shuffle($answers);
    $bot->reply($answers[array_rand($answers)]);
});




Php

Related
php key in array exists Code Example php key in array exists Code Example
all php error report Code Example all php error report Code Example
carbon parse sunday 30 days ago Code Example carbon parse sunday 30 days ago Code Example
home url wordpress Code Example home url wordpress Code Example
how many files in dir php Code Example how many files in dir php Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
7