$colors = array("#000","#F00","#800","#880","#080","#0F0","#0F0","#0F7","#080",  
                  "#08F","#00F","#80F","#80F","#F0F","#F08","#880","#F00");
  $targ_r = 90;
  $targ_i = 160;
  $start_r = -2.00;
  $start_i = -1.40;
  $end_r = -0.30;
  $end_i = 3.60;
  $inc_r = ($end_r - $start_r) / $targ_r;
  $inc_i = ($end_i - $start_i) / $targ_i;
  
  for ($y=0; $y < $targ_r; $y++) {
    $c_i = $start_i + $inc_i * $y;
    for ($x=0; $x < $targ_i; $x++) {
      $c_r = $start_r + $inc_r * $x;
      $z_r = 0; $z_i = 0;
      $count = count($colors) - 1;
      while ($count > 0) {
        $z_r = $z_r * $z_r - $z_i * $z_i + $c_r;
        $z_i = 2 * $z_r * $z_i + $c_i;
        if (($z_i * $z_i + $z_r * $z_r) > 4) break;
        $count = $count - 1;
      }
      echo "<div style=\"background-color:".$colors[(int)($count)].";\"></div>";
    }
    echo "<br/>";
  }