php equilvalant to on duplicate key update?
<p>I find myself using this logic a lot:</p>

<pre><code>if (isset($array[$key]))
        $array[$key] += $num;
else
        $array[$key]  = $num;
</code></pre>

<p>since the keys are dynamically generated I cannot just set them all to zero at the start.</p>

<p>I was wondering if there were a more elegant way of doing this, similar to MySQLs <code>ON DUPLICATE KEY UPDATE</code> logic.</p>
