Click here to Skip to main content
15,917,951 members
Please Sign up or sign in to vote.
1.00/5 (3 votes)
See more:
I have this snippet of Java that i would like to convert to php.
Any help would be highly appreciated.
Java
public class argonpain {
  private String makeSixBits( String binaryStr ) {
    String ret = ""
    StringBuilder zeros = new StringBuilder ();
    int length = binaryStr.length();
    int appends = 6 - length ;
    for ( int i = 0; i < appends ; i ++) {
      zeros.append( "0"); // Append missing 0's to make expected bits
    }
    ret = zeros + binaryStr ;
    return ret ;
  }
}
Posted
Updated 4-May-20 11:33am
v2
Comments
Kornfeld Eliyahu Peter 5-Jan-16 6:51am    
Do you understand this code?
Member 12123296 5-Jan-16 7:04am    
No, am just curious to understand the snippet.
I am a newbie to Java but understand a little bit of php.
Member 12123296 5-Jan-16 7:07am    
I understand it is used to make a 6bit binary of a string.

1 solution

PHP
str_pad($binaryStr, 6, "0", STR_PAD_LEFT);
 
Share this answer
 

This content, along with any associated source code and files, is licensed under The Code Project Open License (CPOL)



CodeProject, 20 Bay Street, 11th Floor Toronto, Ontario, Canada M5J 2N8 +1 (416) 849-8900