Decimal To Octal

This algorithm converts decimal numbers to octal numbers.



									function DecimalToOctal($dec)
{
	if ($dec < 1) return "0";

	$octStr = "";

	while ($dec > 0)
	{
		$octStr = substr_replace($octStr, strval($dec % 8), 0, 0);
		$dec = floor($dec / 8);
	}

	return $octStr;
}
								


Example

									$data = 667887;
$value = DecimalToOctal($data);
								


Output

									2430357