Welcome to collectivesolver - Programming & Software Q&A with code examples. A website with trusted programming answers. All programs are tested and work.

Contact: aviboots(AT)netvision.net.il

Buy a domain name - Register cheap domain names from $0.99 - Namecheap

Scalable Hosting That Grows With You

Secure & Reliable Web Hosting, Free Domain, Free SSL, 1-Click WordPress Install, Expert 24/7 Support

Semrush - keyword research tool

Boost your online presence with premium web hosting and servers

Disclosure: My content contains affiliate links.

39,912 questions

51,844 answers

573 users

How to show 8 bits of a char (byte) in PHP

2 Answers

0 votes
$ch = 'a';
    
$bin = decbin(ord($ch));

echo $bin;



/*
run:
     
1100001
 
*/

 



answered Nov 23, 2017 by avibootz
0 votes
$ch = 'a';
    
$bin = decbin(ord($ch));
$bin = str_pad($bin, 8, 0, STR_PAD_LEFT);

echo $bin;



/*
run:
     
01100001
 
*/

 



answered Nov 23, 2017 by avibootz

Related questions

1 answer 96 views
96 views asked Sep 13, 2024 by avibootz
1 answer 171 views
171 views asked Nov 23, 2017 by avibootz
1 answer 157 views
157 views asked Nov 23, 2017 by avibootz
1 answer 120 views
1 answer 48 views
1 answer 117 views
...