2017 © Pedro Peláez
 

library php-bits

Make bitwise operations easier in PHP

image

titasgailius/php-bits

Make bitwise operations easier in PHP

  • Tuesday, May 16, 2017
  • by TitasGailius
  • Repository
  • 1 Watchers
  • 0 Stars
  • 2 Installations
  • PHP
  • 0 Dependents
  • 0 Suggesters
  • 0 Forks
  • 0 Open issues
  • 2 Versions
  • 100 % Grown

The README.md

PHPBits

Advanced bitwise operations using PHP made simplier

Installation

With composer

$ composer install titasgailius/php-bits, (*1)

{
    "require": {
        "titasgailius/php-bits": "~1.00"
    }
}

Examples

<?php

require 'vendor/autoload.php';

use PHPBits\Bits;

/**
 * Convert string to a binary string
 *
 * Bits::strbin(string $string) : string
 */
Bits::strbin('Hello'); // "0100100001100101011011000110110001101111"

/**
 * Converts string to a decimal number representation
 *
 * Bits::strdec(string $string) : int
 */
Bits::strdec('Hello'); // 310939249775

/**
 * Converts an integer to a binary string
 *
 * Bits::decbin(int $integer, int $length = 8) : string
 */
Bits::decbin(10); // 00001010
Bits::decbin(10, 16); // 0000000000001010

/**
 * Get count of bits in a string
 *
 * Bits::strlen(string $string) : int
 *
 */
Bits::strlen('Hello');  // 40

/**
 * Rotate integer's bits to left by 1 position and return new integer

 * Bits::decRotateLeft(int $integer, int $positions = 1) : int
 */
Bits::decRotateLeft(10);
// 20, because 10 is "00010100" in binary so rotated it's "00010100" which is 20.

The Versions

16/05 2017

dev-master

9999999-dev

Make bitwise operations easier in PHP

  Sources   Download

The Development Requires

by Titas Gailius

php bits bitwise operations strbin strdec decbin strlen

16/05 2017

v1.0

1.0.0.0

Make bitwise operations easier in PHP

  Sources   Download

The Development Requires

by Titas Gailius

php bits bitwise operations strbin strdec decbin strlen