1
gruessle
AgendaX need help with rand hack
  • 2003/11/23 2:12

  • gruessle

  • Friend of XOOPS

  • Posts: 348

  • Since: 2003/9/20


Need some help
Random picture location with correct extention.

In echo '.$random.' returns not the number but the code.


<?php // logic echoing any image url srand ((double) microtime() * 1000000); $randloc = rand(1,2); $random_url = array( "", "/image_loc_1/", "/image_loc_2/", ); $random_img = array( "", ".gif", ".jpg", ); if ($randloc == 1) $random = rand(1,25); else $random .= rand(1,99); echo ''.$random_url[$randloc].''.$random.''.$random_img[$randloc].'" width="140"'; ?>

2
gruessle
Re: AgendaX need help with rand hack
  • 2003/11/23 2:34

  • gruessle

  • Friend of XOOPS

  • Posts: 348

  • Since: 2003/9/20


I got it working here is the code

<?php // logic echoing any image url srand ((double) microtime() * 1000000); $randloc = rand(1,2); $random1 = rand(1,25); $random2 = rand(1,99); if ($randloc == 1) echo '/image1/'.$random1.'.gif" width="140"'; else echo '/image2/'.$random2.'.jpg" width="140"'; ?>