Division by zero error in a code : <pre><code>public function convert($value, $from, $to) {
    if ($from == $to) {
        return $value;
    }

    if (isset($this-&gt;lengths[$from])) {
        $from = $this-&gt;lengths[$from]['value'];
    } else {
        $from = 0;
    }

    if (isset($this-&gt;lengths[$to])) {
        $to = $this-&gt;lengths[$to]['value'];
    } else {
        $to = 0;
    }       

    return $value * ($to / $from);
}
</code></pre>

<p>This code is giving division by zero error on the line "return $value * ($to/$from)" . Can any one debug this . </p>
