PHP function to move decimal to beginning
<p>I need a function in PHP to move the decimal to the beginning of the number if one exists otherwise if there is no decimal add 0. to the beginning.</p>

<p>I have:</p>

<pre><code>function toDecimal($input){
    return (stripos($input, ".")!==false)? $input: "0." . $input;
}
</code></pre>

<p>which was provided in a previous question of mine (thanks @shiplu.mokadd.im) but I need to extend it to also move the decimal to the beginning like:</p>

<pre><code>Input        Output
0.1234       0.1234
1.2345       0.12345
1234         0.1234
0.001234     0.001234
</code></pre>

<p>so basically the outputted number can never be larger than 1.</p>

<p>Thanks!</p>
