Math.random() and "hexChars" PHP equivalents
<p>I am trying to convert a JavaScript to php but I am not sure how to convert <code>Math.random()</code> and <code>hexChars</code> method in below JavaScript function to PHP, thanks for any help</p>

<p><strong>JavaScript function:</strong></p>

<pre><code>    function generateId(){
        var a=[],b;
        a[8]=a[13]=a[18]=a[23]="-";
        a[14]="4";

        for(i=0;i&lt;36;i++)
        if(!a[i]){
            b=0|Math.random()*16;
            a[i]=hexChars[i==19?b&amp;3|8:b]
        }
        return a.join("")       
    }
</code></pre>

<p><strong>PHP function</strong> I converted so far:</p>

<pre><code>function generateId(){
    $a = array();
    $a[8]=$a[13]=$a[18]=$a[23]="-";
    $a[14]="4";
    for($i=0;$i&lt;36;$i++){
        if(!$a[$i]){
        // not sure what to do here 
        }
    }
}
</code></pre>

<p>Edit: 
it will create a string like this: 902EA4DD-5445-4435-93F2-2A5203818255</p>
