Logo Questions Linux Laravel Mysql Ubuntu Git Menu
 

How to convert base64 string to binary array using php

I have base 64 encoded string that looks something like this.

cuVrcYvlqYze3OZ8Y5tSqQY205mcquu0GsHkgXe4bPg=

I have tried base64_decode and output is.

råkq‹å©ŒÞÜæ|c›R©6Ó™œªë´Áäw¸lø

I think I may be doing something wrong. I appreciate any help to convert base64 string to binary array.

Thanks

like image 714
Nick Avatar asked Sep 19 '10 10:09

Nick


1 Answers

like this

$a = base64_decode("cuVrcYvlqYze3OZ8Y5tSqQY205mcquu0GsHkgXe4bPg=");
$b = array();
foreach(str_split($a) as $c)
    $b[] = sprintf("%08b", ord($c));
print_r($b);
like image 135
user187291 Avatar answered Nov 02 '22 17:11

user187291