unpack

Supported Versions: PHP 4, PHP 5, PHP 7, PHP 8
Unpack data from binary string
<?php unpack(string $format, string $string, int $offset = 0): array|false
<?php     public function getHash()

    {

        $data = unpack('ihash', md5(implode(',', $this->literals), true));



        return $data['hash'];

    }
<?php     public function getHash()

    {

        $data = unpack('ihash', md5('c:'.implode(',', $this->literals), true));



        return $data['hash'];

    }
<?php     protected function matchRange(stdClass $network, stdClass $target)

    {

        $net = unpack('C*', $network->ip);

        $mask = unpack('C*', $network->netmask);

        $ip = unpack('C*', $target->ip);
<?php     protected function matchRange(stdClass $network, stdClass $target)

    {

        $net = unpack('C*', $network->ip);

        $mask = unpack('C*', $network->netmask);

        $ip = unpack('C*', $target->ip);



        for ($i = 1; $i < 17; ++$i) {
<?php     {

        $net = unpack('C*', $network->ip);

        $mask = unpack('C*', $network->netmask);

        $ip = unpack('C*', $target->ip);



        for ($i = 1; $i < 17; ++$i) {

            if (($net[$i] & $mask[$i]) !== ($ip[$i] & $mask[$i])) {
<?php         $netmask = $this->ipGetMask($prefix, $size);




        $mask = unpack('C*', $netmask);

        $ip = unpack('C*', $rangeIp);

        $net = '';
<?php         $mask = unpack('C*', $netmask);

        $ip = unpack('C*', $rangeIp);

        $net = '';



        for ($i = 1; $i < 17; ++$i) {
<?php     {

        $rule = new GenericRule(array(123), Rule::RULE_ROOT_REQUIRE, array('packageName' => '', 'constraint' => new MatchAllConstraint));



        $hash = unpack('ihash', md5('123', true));

        $this->assertEquals($hash['hash'], $rule->getHash());

    }