lundi 31 octobre 2016

Using text file separated with comma for get Random phrases

I want add my personal blog one random message when one user visit at first time the blog or when refresh the site, I'm using a text file (separated by a comma) with the following content:

Hello! Welcome,have a nice day,the best it's be happy!

I have added to my page the following code:

<?php include('message.php');?>

content from my message.php:

    $text = file_get_contents('./saludo/hola.txt');
    $textArray = explode(",", $text);
    $randArrayIndexNum = array_rand($textArray);
    $saludo = $textArray[$randArrayIndexNum];

the problem is that when i use this show all messages:

Hello! Welcome,have a nice day,the best it's be happy!

and i want to show only 1 message:

Hello! Welcome

how could I fix this and display only a message and using a comma.

Regards!.




Aucun commentaire:

Enregistrer un commentaire