999) { return $in; } // return as initial numeric string // If I is initially 0, and there is an additive tuple with a weight of 0, append that tuple's counter glyph to S and return S. if ($i === 0) { return '0'; } // Otherwise, while I is greater than 0 and there are elements left in the glyph list: $additiveNumsCount = count($additive_nums); for ($t = 0; $t < $additiveNumsCount; $t++) { // Pop the first additive tuple from the glyph list. This is the current tuple. $ct = $additive_nums[$t]; // Append the current tuple's counter glyph to S x floor( I / current tuple's weight ) times (this may be 0). $n = floor($i / $ct); for ($j = 0; $j < $n; $j++) { if (is_array($additive_glyphs[$t])) { foreach ($additive_glyphs[$t] as $ag) { if ($reverse) { $s = UtfString::code2utf($ag) . $s; } else { $s .= UtfString::code2utf($ag); } } } else { if ($reverse) { $s = UtfString::code2utf($additive_glyphs[$t]) . $s; } else { $s .= UtfString::code2utf($additive_glyphs[$t]); } } $i -= ($ct * $n); } if ($i === .0 || $i === 0) { return $s; } } return $in; // return as initial string } }