Convert JS code to PHP
<pre><code>var base64 = new Encodeutil.Base64Binary("");
    lstApplicableSubs = new Array(lstCategories.length);
    for (var i = 0; i &lt; lstApplicableSubs.length; i++) lstApplicableSubs[i] = new Array();
    for (i = 0; i &lt; lstSubCategories.length; i++)
    {
        var map = base64.decode(lstSubCategories[i].validFor);
        for (var j = 0; j &lt; lstCategories.length; j++)
        {
            var bits = map.charCodeAt(j &gt;&gt; 3);
            if ((bits &amp; (0x80 &gt;&gt; (j &amp; 0x07))) != 0) lstApplicableSubs[j].push(lstSubCategories[i]);
        }
    }
</code></pre>

<p>Can anyone help convert this to PHP?</p>

<p>Below is var_export for object : </p>

<pre><code>stdClass::__set_state(array(
  array (
    0 =&gt; 
    stdClass::__set_state(array(
       'label' =&gt; 'Category',
       'name' =&gt; 'Category',
       'optionslist' =&gt; 
      array (
        0 =&gt; 
        stdClass::__set_state(array(
           'label' =&gt; 'Category1',
           'value' =&gt; 'Category1',
        )),
        1 =&gt; 
        stdClass::__set_state(array(
           'label' =&gt; 'Category2',
           'value' =&gt; 'Category2',
        )),
        2 =&gt; 
        stdClass::__set_state(array(
           'label' =&gt; 'Category3',
           'value' =&gt; 'Category3',
        )),
        3 =&gt; 
        stdClass::__set_state(array(
           'label' =&gt; 'Category4',
           'value' =&gt; 'Category4',
        )),
    )),
    1 =&gt; 
    stdClass::__set_state(array(
       'label' =&gt; 'Sub Category',
       'name' =&gt; 'Sub_Category',
       'optionslist' =&gt; 
      array (
        0 =&gt; 
        stdClass::__set_state(array(
           'label' =&gt; 'SubtCategory1',
           'validFor' =&gt; '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '' . "\0" . '',
           'value' =&gt; 'SubtCategory1',
        )),
        1 =&gt; 
        stdClass::__set_state(array(
           'label' =&gt; 'SubtCategory2',
           'validFor' =&gt; '' . "\0" . '' . "\0" . '',
           'value' =&gt; 'SubtCategory2',
        )),
    ),
))
</code></pre>
