Here’s a quick example of weighted round robin in php.

//weighted round robin
 
define("START_WEIGHT", 1);
class printer
{
  private $name;
  private $weight;
  private $normalizedWeight;
  public function printer($name,$weight=START_WEIGHT)
  {
    $this->name=$name;
    $this->weight=$weight;
  }
  public function getName() { return $this->name; }
  public function getWeight() { return $this->weight; }
  public function setWeight($weight) { $this->weight=$weight; }
  public function getNormalizedWeight(){ return $this->normalizedWeight; }
  public function setNormalizedWeight($weight) { $this->normalizedWeight=$weight; }
 
}
 
$printerList=array();
$printerList[]=new printer("printer1",1);
$printerList[]=new printer("printer2",2);
$printerList[]=new printer("printer3",4);
$printerList[]=new printer("printer4",1);
 
$jobList=array(‘job1′,‘job2′,‘job3′,‘job4′,‘job5′,‘job6′,‘job7′,‘job8′,‘job9′,‘job10′,‘job11′,‘job12′,‘job13′,‘job14′,‘job15′,‘job16′);
 
$min=2147483647; //a large number
foreach($printerList as $printer)
{
  $min=($printer->getWeight()<$min)?$printer->getWeight():$min;
}
foreach($printerList as $printer)
{
  $printer->setNormalizedWeight($printer->getWeight()/$min);
}
 
$jobCount=count($jobList);
while($jobCount>0)
{
  foreach($printerList as $printer)
  {
    $jobCount=count($jobList);
    if ($jobCount>0)
    {
      $jobList=jobPush($printer,$jobList,$jobCount);
    }
  }
}
 
function jobPush($printer,$jobList,$jobCount)
{
  for($x=0;$x<$printer->getNormalizedWeight();$x++)
  {
    if ($jobCount>0)
    {
      $job=array_shift($jobList);
      $jobCount–;
      echo($printer->getName()." getting ".$job."n");
    }
  }
  echo("n");
  return $jobList;
}