PHP programming forum. Ask questions or help people concerning PHP code. Don't understand a function? Need help implementing a class? Don't understand a class? Here is where to ask. Remember to do your homework!
function shuffle(array) {
var m = array.length, t, i;
while (m) { // While there remain elements to shuffle ...
i = Math.floor(Math.random() * m--); // Pick a remaining element ...
t = array[m]; // And swap it with the current element...
array[m] = array[i];
array[i] = t;
}
return array;
}
can PHP so this and be as object oriented?
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
Okay, well, I'd bet that array_rand() is better suited to your purposes but shuffle() may be more appropriate depending on a lot of details which you don't seem to want to give.
Just a thought, but if I was an advertiser purchasing space on your site I'd want some reassurance that whether or not my ads are displayed isn't subject to some random arbitrary algorithm Normally, ad space would be sold on the number of page impressions, so you should be keeping a count of how often those ads appear and then deactivating them after the maximum number of page impressions has been reached.
Also, how is not wanting to see your ads a form of copyright infringement? Perhaps a breach of the site's terms and conditions maybe, but this still seems rather draconian and - as requinix has suggested - I'd go elsewhere if your site stopped me accessing it or displayed some legal notice. Also, how does that look from the advertisers' perspective? There is too much competition from other sites to risk losing valuable visitors. And what if the ad-blocking isn't opt-in - let's say the visitor is using an Internet cafe or Wi-Fi network where the firewall blocks this kind of content, or a work computer where the IT support have installed it by default?
Ad blocking is now so pervasive I had to do something to keep some $ flowing in, video cards are expensive
I reconcile my server logs with google and my ad agency all to see if current countermeasures are effective or not and if I need to get back to the drawing board.
The internet economy depends on income from ads, just like TV, radio and so on.
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP
I certainly don't disagree with the point you're making, but I don't think it's viable to specifically exclude people from a site just because they don't want to see your ads - a permissive policy would be much better, and (as an example) although I am well aware of the existence of ad blockers, I don't install them in my browsers because I understand that some sites rely on ads for their income. Similarly, I won't listen to a radio station if their advertising is too pervasive or visit a site if their advertising methods are too aggressive. Whether or not these advertising models are sustainable is not really my concern unless I'm reliant on that service, so it's better to "reward" loyalty and not "punish" disloyalty - even if a person is being "disloyal" by blocking your advertising, they might recommend your site to someone else who isn't or (in the wider scheme of things) improve your position with advertisers because the demographics of your site are much better and the audience larger as a result of accommodating "disloyal" visitors.
function shuffle(array) {
var m = array.length, t, i;
while (m) { // While there remain elements to shuffle ...
i = Math.floor(Math.random() * m--); // Pick a remaining element ...
t = array[m]; // And swap it with the current element...
array[m] = array[i];
array[i] = t;
}
return array;
}
Hardcore Games™ Legendary is the Only Way to Play™
My site is powered by LAMP