Hello, I have a certain number of phrases, and I need every time the user sends a certain form, one of these phrases appears, using a random function, but I do not know how to start, I have no code so far.
Hello, I have a certain number of phrases, and I need every time the user sends a certain form, one of these phrases appears, using a random function, but I do not know how to start, I have no code so far.
Try this way
$array = array(
'Frase 1',
'Frase 2',
'Frase 3'
);
$aleatorio = rand(0, count($array) -1);
echo $array[$aleatorio];
From what you specified in your question I can give you an idea how to do this in a simple way, use an array to store your sentences and have the array_rand () function return an index randomly chosen phrase.
$frases = array('frase 1','frase 2','frase 3','frase 4');
echo $frases[array_rand($frases)];
See working at Ideone