You want to use pack
and base_convert
.
// Convert a string into binary
// Should output: 0101001101110100011000010110001101101011
$value = unpack('H*', "Stack");
echo base_convert($value[1], 16, 2);
// Convert binary into a string
// Should output: Stack
echo pack('H*', base_convert('0101001101110100011000010110001101101011', 2, 16));
Related Contents:
- PHP sessions in a load balancing cluster – how?
- How create an array from the output of an array printed with print_r?
- Populating nested dropdowns using backpack for Laravel
- cURL error 60: SSL certificate in Laravel 5.4
- php date validation
- Obtain first line of a string in PHP
- Check file uploaded is in csv format
- MySQL get a random value between two values
- Set Application_ENV via virtual host config and read this in PHP
- Doctrine2 Insert and retrieve new insert ID
- How to define global functions in PHP
- Replace string in text file using PHP
- Expected response code 250 but got code “530”, with message “530 5.7.1 Authentication required
- naming tables in many to many relationships laravel
- Accessing array values using array key from Twig
- PHPExcel very slow – ways to improve?
- PHP MySQLI Prevent SQL Injection [duplicate]
- PHP If Statement with Multiple Conditions
- Catching Stripe errors with Try/Catch PHP method
- php switch case statement to handle ranges
- Laravel Soft Delete posts
- How to delete element with DOMDocument?
- curl posting with header application/x-www-form-urlencoded
- Finding n-th permutation without computing others
- What exactly is the difference between the is_callable and function_exists in PHP?
- How to convert text to SVG paths?
- How to make Apache serve index.php instead of index.html?
- Search for PHP array element containing string [duplicate]
- Encrypt and Decrypt text with RSA in PHP
- Logging full stack trace with Monolog
- What is the difference between destroy() and delete() methods in Laravel?
- Storing and displaying unicode string (हिन्दी) using PHP and MySQL
- PHP Default Function Parameter values, how to ‘pass default value’ for ‘not last’ parameters?
- Using print_r and var_dump with circular reference
- Getting mime type from file name in php
- PHP, How to get current date in certain format [duplicate]
- Can I detect IE6 with PHP?
- Getting “Indirect modification of overloaded property has no effect” notice
- Make array of all GET-variables
- Get file content from URL?
- PHP CLI won’t log errors
- PHP: Testing whether three variables are equal
- Working days (Mon-Fri) in PHP
- How to access the php.ini file in godaddy shared hosting linux
- Passing parameters to PHPUnit
- How can I get MAMP to tell me what went wrong with php code?
- Laravel 5.4 – Validation with Regex [duplicate]
- How to get system environment variables into PHP while running CLI & Apache2Handler?
- Is there a way to do an “INSERT…ON DUPLICATE KEY UPDATE” in Zend Framework 1.5?
- phpunit – testing is painfully slow