php - Output random string stored in array -


hello once again stackoverflow. i've been working on in php. now, require php picks random value in array have , outputs it. but, not make same every time, change everytime page loaded.

what have far:

    <?php $a=array("value 1", "value 2", "value 3", "value 4", "value 5"); $random_keys=array_rand($a); echo $random_keys; ?> 

now, i've tried script outputs numbers instead of value. doing wrong?

do:

<?php $a=array("value 1", "value 2", "value 3", "value 4", "value 5"); $random_keys=array_rand($a); echo $a[$random_keys]; 

array_rand returns key not value. need use key return value above.


Comments

Popular posts from this blog

android - Get AccessToken using signpost OAuth without opening a browser (Two legged Oauth) -

org.mockito.exceptions.misusing.InvalidUseOfMatchersException: mockito -

google shop client API returns 400 bad request error while adding an item -