almightyegg Posted November 13, 2006 Share Posted November 13, 2006 i want to randomise whicch code is shown like:page 1:echo "This is page 1;page 2:echo "This is page 2";etc....how would ido this??? Link to comment https://forums.phpfreaks.com/topic/27146-randomising-code/ Share on other sites More sharing options...
trq Posted November 13, 2006 Share Posted November 13, 2006 [url=http://php.net/rand]rand[/url]. Link to comment https://forums.phpfreaks.com/topic/27146-randomising-code/#findComment-124117 Share on other sites More sharing options...
almightyegg Posted November 13, 2006 Author Share Posted November 13, 2006 i thought rand() could only deal with numbers ??? Link to comment https://forums.phpfreaks.com/topic/27146-randomising-code/#findComment-124119 Share on other sites More sharing options...
blear Posted November 13, 2006 Share Posted November 13, 2006 Have no idea what you're asking here Link to comment https://forums.phpfreaks.com/topic/27146-randomising-code/#findComment-124124 Share on other sites More sharing options...
almightyegg Posted November 13, 2006 Author Share Posted November 13, 2006 rand() can only deal with numbers...and i want to randomise whole pages of information.... Link to comment https://forums.phpfreaks.com/topic/27146-randomising-code/#findComment-124125 Share on other sites More sharing options...
trq Posted November 13, 2006 Share Posted November 13, 2006 Look though....[code]<?php $page = rand(1,5); include 'page'.$page.'.php';?>[/code] Link to comment https://forums.phpfreaks.com/topic/27146-randomising-code/#findComment-124126 Share on other sites More sharing options...
The Little Guy Posted November 13, 2006 Share Posted November 13, 2006 [code]<?php$rand = rand(1,3);switch($rand){case 1:$page = "page1.php"break;case 2:$page = "page2.php"break;case 3:$page = "page3.php"break;}include "$page";?>[/code] Link to comment https://forums.phpfreaks.com/topic/27146-randomising-code/#findComment-124163 Share on other sites More sharing options...
trq Posted November 13, 2006 Share Posted November 13, 2006 You managed to do in 13 lines what I did in 2. Hehe. It might be a clearer example though. Link to comment https://forums.phpfreaks.com/topic/27146-randomising-code/#findComment-124170 Share on other sites More sharing options...
The Little Guy Posted November 13, 2006 Share Posted November 13, 2006 your way will require the page to be an number (page23.php), and mine doesn't, it allows you to define what each page that you want randomized. Link to comment https://forums.phpfreaks.com/topic/27146-randomising-code/#findComment-124172 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.