i am creating random numbers with .ASP That code snippet createing random numbers between 1-38. How can i do that in PHP?
<img src="images/randım/picture-<?=rand(1,39)?>.jpg"> Php automaticaly uses randomize, and rand() returns int.
OHHH!!!!! Thats GREAT!!!!! Thank you so much "er2er" How can i do this with a variable? <img src="images/randım/picture-<?=my_variable?>.jpg">
In PHP variables starts with $, so <img src="images/randım/picture-<?=$my_variable?>.jpg"> Some theory: ;-) <? is short php opening tag (equivalent og <?php) and ?> is a closing tag <?=... ?> is an equivalent of <? echo ... ?> (outputs ...) Now, you can use for example: <? $my_random = rand(1,39); ?> PHP: and then: <img src="images/random/picture-<?=$my_variable?>.jpg"> If you want to use more advanced pseudo-random number generator, you can try mt_randomize() and mt_rand(1,39) - just to play with php