thisismyurl Posted September 25, 2009 Share Posted September 25, 2009 Hi all, this may be a silly question but I'm trying to convert a file to a string of 1's and 0's but I keep getting stuck. $n = 123456; printf("%%b = '%b'\n", $n); and get %b = '11110001001000000' but when I try $n = "hello"; printf("%%b = '%b'\n", $n); I get %b = '0' What I'm trying to do is load a JPG and store it as '11110001001000000 ...' If I load the file like this: $file = file('test.jpg',FILE_BINARY); foreach ($file as $line) { $totalfile .= $line; } Is there a way for me to convert $totalfile to a binary string like '11110001001000000 ...' ? Link to comment https://forums.phpfreaks.com/topic/175507-converting-a-file-to-binary-1s-and-0s/ Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.