Rianna Posted September 3, 2006 Share Posted September 3, 2006 Hello, I would like to change some php to calling on something by day.The one I have only calls on something randomly. Do you know how I canalter this string to accomodate this? Thanks! $banner_no = (rand()%(count($s_con)-1));Just so you know what the above does, gets a random number which is in the content of my file. for instance if I have 1-some text2-different text3-some other textIt grabs one of these numbers and the text along with it to display randomly. I would like it to display by day and in order instead. Quote Link to comment Share on other sites More sharing options...
zq29 Posted September 3, 2006 Share Posted September 3, 2006 If you number them 0 - 6, zero being Sundays text and 6 being Saturdays text, you can grab todays text with date("w"). Quote Link to comment Share on other sites More sharing options...
Rianna Posted September 4, 2006 Author Share Posted September 4, 2006 Not sure what you mean, can you show me a string for this please, to use instead of mine. Thank you very much! Quote Link to comment Share on other sites More sharing options...
Jenk Posted September 4, 2006 Share Posted September 4, 2006 [code]<?php$days = array( 'Sundays text', 'Mondays text, /* etc */ 'Saturdays text');echo $days[array_rand($days)];?>[/code] Quote Link to comment Share on other sites More sharing options...
zq29 Posted September 4, 2006 Share Posted September 4, 2006 [quote author=Rianna link=topic=106716.msg427550#msg427550 date=1157348033]Not sure what you mean, can you show me a string for this please, to use instead of mine. Thank you very much![/quote]Sure, your file would contain:0-Sundays text1-Mondays text2-Tuesdays text3-Wednesdays text4-Thursdays text5-Fridays text6-Saturdays textAnd to get todays text, you'd do something like this:$banner_no = date("w"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.