Quantcast
Channel: PHP Freaks: PHP Help
Viewing all articles
Browse latest Browse all 13200

Help needed on a simple question

$
0
0

Hi Guys,

 

I have a very basic question that I cannot seem to answer ... so would appreciate any help / advise.

 

Code snippet:

$Text1="Hi, how are you";
$Text2="Hey there stranger";
$Text3="Its about time!";

$random_number = rand(1,3); 
$WelcomeText = "$"."Text".$random_number;
echo $WelcomeText;


The above script generates the output as $Text3 but what I am trying to achieve is this output: Its about time!

 

 

I know I can use an array and output the value ... but I wanted to know -- why the above code would not work.

 

Any help / explaination would be great!

 

Thanks :)

 


Viewing all articles
Browse latest Browse all 13200

Trending Articles