I need to display one of two elements in an array based on a 40/60% ratio. Thus, 40% of the time, the first item is displayed and 60% of the time, item 2 is displayed.
Now I have the following code that will just randomly choose between them, but I need a way to add percentage weight to it.
$items = array("item1","item2"); $result = array_rand($items, 1); echo $items[$result];
Any help would be greatly appreciated. Thanks!
source share