public function arrayToBinary($val)
    {
        $saved_object_count = $this->writtenObjectCount++;

        $bdata = self::typeBytes("a", count($val->getValue())); // a is 1010, type indicator for arrays

        foreach ($val as $v) {
            $bval = $v->toBinary($this);
            $bdata .= self::packItWithSize($this->objectRefSize, $bval);
        }

        $this->objectTable[$saved_object_count] = $bdata;
        return $saved_object_count;
    }