mardi 27 janvier 2015

array rand pick one or more random entries

I have this code it's choose random name from the comments.txt file



<?php $f_contents = file("comments.txt");
$line = $f_contents[array_rand($f_contents)];
$messages = $line; ?>


I need to make it choose from this data below



$messages = $_POST ['0'];
$messages2 = $_POST ['1'];
$messages3 = $_POST ['2'];


example:



<?php
$f_contents = $messages,$messages2,$messages3;
$line = $f_contents[array_rand($f_contents)];
$messages = $line;
?>




Aucun commentaire:

Enregistrer un commentaire