Join the social network of Tech Nerds, increase skill rank, get work, manage projects...
 
  • How to convert string to binary and binary to string using PHP

    • 0
    • 0
    • 0
    • 0
    • 1
    • 0
    • 0
    • 0
    • 7.42k
    Comment on it

    Hello Readers if you want to convert your string into binary using PHP then you can use the code syntax as below:-

    $value = unpack('H*', "This string is converting into binary");
    echo base_convert($value[1], 16, 2);
    

    Output:-

    0101001101110100011000010110001101101011
    

    and you again want to convert binary to string then you just have to user pack syntax

    Now this syntax will go like this:-

    echo pack('H*', base_convert('0101001101110100011000010110001101101011', 2, 16));
    

    Output:-

    This string is converting into binary
    

 1 Comment(s)

Sign In
                           OR                           
                           OR                           
Register

Sign up using

                           OR                           
Forgot Password
Fill out the form below and instructions to reset your password will be emailed to you:
Reset Password
Fill out the form below and reset your password: