PHP Program to Converter a Decimal to Octal

You are Here:

Converter a Number from Decimal to Octal

In the following example, we will convert a Decimal Number (100) to Octal Number (144).

Tips: It is recommended to use our online Decimal to Octal calculator for better understanding.


PHP Compiler
<?php $num = 23456; $arr = []; $answer = []; $value = 1; $j = 0; $count = -1; while($num > $value) { $count++; $value = pow(8, $count); $arr[$count] = $value; } $count = $count - 1; for($i=$count; $i>=0; $i--) { $answer[$j] = floor($num / $arr[$i]); $j++; $num = $num % $arr[$i]; } echo "Octal number of 23456 (decimal) is "; for($i=0; $i<=$count; $i++) echo $answer[$i]; ?>


Octal number of 23456 (decimal) is 55640


Hi Developers, we almost covered 90% of String functions and Interview Question on PHP with examples for quick and easy learning.

We are working to cover every Single Concept in PHP.

Please do google search for:

Join Our Channel

Join our telegram channel to get an instant update on depreciation and new features on HTML, CSS, JavaScript, jQuery, Node.js, PHP and Python.

This channel is primarily useful for Full Stack Web Developer.

Share this Page

Meet the Author