Ravens PHP Scripts: Forums
 

 

View next topic
View previous topic
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks
Author Message
galat514
New Member
New Member


Joined: Feb 09, 2006
Posts: 4

PostPosted: Thu Feb 09, 2006 8:53 am Reply with quote

I am trying to set up a block that displays different texts. In general, I want different text depending on which module is currently being loaded. I can query the $name variable to determine the current module and switched based on that. In certain modules, I want random text. I have several things I want to include, so the most logical is rand() and a switch. The catch is that I want the text to be weighted. That is, one text should appear 20% of the time, three others 10% the rest then share the remaining 50%.

The way I did it was a double switch:
switch rand:
< 2 do text1
< 3 and > 1 do text2
> 4 do inner_switch

This seems a bit of a hack and I was wondering if someone had a simpler solution.
 
View user's profile Send private message
montego
Site Admin


Joined: Aug 29, 2004
Posts: 9453
Location: Arizona

PostPosted: Mon Feb 13, 2006 7:18 am Reply with quote

I would first switch on the module name (since you said only some modules will need this "weighting"). Then within the modules you want this weighting to occur, go ahead and use the method you mentioned above. It aleady is pretty "simple" and works right? Wink

_________________
Only registered users can see links on this board! Get registered or login!
Only registered users can see links on this board! Get registered or login! 
View user's profile Send private message Visit poster's website
Display posts from previous:       
Post new topic   Reply to topic    Ravens PHP Scripts And Web Hosting Forum Index -> Blocks

View next topic
View previous topic
You cannot post new topics in this forum
You cannot reply to topics in this forum
You cannot edit your posts in this forum
You cannot delete your posts in this forum
You cannot vote in polls in this forum
You can attach files in this forum
You can download files in this forum


Powered by phpBB © 2001-2007 phpBB Group
All times are GMT - 6 Hours
 
Forums ©