Jump to content

CyberLawrence

New Members
  • Posts

    6
  • Joined

  • Last visited

Everything posted by CyberLawrence

  1. Correct, I am aware that all those numbers are the same just in different number bases. My issue is the data coming from the HTML Form is not numeric. I convert it to binary from what I receive as HEX in text format. The variable $binary3 will never be the same number.... so it has to be a variable. Your code works great for manually entering the binary code. AH HA! Got it. I don't need to convert it to binary. I just convert it to decimal and use your code to "strip" the bits out of the decimal number! Thumbs up to you sir! I was converting to binary to see if my code was working correctly and got stuck on that.... Thanks to all!
  2. Entering as HEX via the HTML form... converting to binary in order to get individual bits as variables. My breakdown is between the form and assigning the binary representation to a variable name. Barand's code is fine... I just need to get to this point ---> $binary3 = 0b10110001; from this point $WORD = $_POST["BYTE"]; $binary3 = (base_convert($WORD,16,2)); <------ shouldn't this give me that ^
  3. Apparently I'm not getting what I need from the form, ie. actual numbers. I must be getting strings of numbers without base types? 0b, 0x, .. I gotta look over some HTML code... or find out how to convert the string into a number.
  4. string(8) "10100001"
  5. I'll give Barand's solution a try. I am taking in HEX from a html form (FF, EF, A1....) then using baseconvert to convert that to binary. that's where the "binary" is coming from. Obviously its not true binary... After the HEX gets converted... shouldn't it look like this as Barand has it? 0b10110001
  6. This might be an easy fix. I need to break an 8 bit binary number into 8 separate variables. When using unpack(), it pushes the first zeros it finds to the back as NULLs 0111 1111 gets translated at 1111 111 null $binary3 = 01111111; list($b7, $b6, $b5, $b4, $b3, $b2, $b1, $b0) = array_values(unpack('c*', $binary3)); var_dump($b7, $b6, $b5, $b4, $b3, $b2, $b1, $b0); My OUTPUT -----HIBYTE------ 7f HEX 01111111 -----LOBYTE------ 7f HEX 01111111 -----DATABYTE------ 7f HEX 01111111 --------------- int(49) int(49) int(49) int(49) int(49) int(49) int(49) NULL int(49) int(49) int(49) int(49) int(49) int(49) int(49) NULL int(49) int(49) int(49) int(49) int(49) int(49) int(49) NULL Bit 0 is Bit 1 is 49 Bit 2 is 49 Bit 3 is 49 Bit 4 is 49 Bit 5 is 49 Bit 6 is 49 Bit 7 is 49
×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.