I know, It's not my original code, i'm setting up a server, actually and it was one of the errors it was recieving.
Originally Posted by Jason
You don't index into arrays with curly braces "{}" to index arrays in PHP, you use square ones [].
i.e:
Code:
$bin .= chr(hexdec($str{$i}.$str{($i + 1)}));
Should actually be
Code:
$bin .= chr(hexdec($str[$i].$str[$i + 1]));
However this code isn't going to do what the function name implies (convert a hexadecimal string into a binary string).
It doesn't matter. PHP is weird, but still a nice language. Curly braces (a.k.a. curly brackets: { }) as well as braces (a.k.a. brackets: [ ]) are just fine. People tend to use brackets because that looks better.
@Cyaphex Do you still need help? Cause I might have the solution for you. You should clearify your question how ever.
Both $convertFrom and $convertTo have to be between 2 and 36, inclusive. Digits in numbers with a base higher than 10 will be represented with the letters a-z, with a meaning 10, b meaning 11 and z meaning 35. You probably don't want to change this, since you only want a hex2bin. If you want bin2hex, just swap the variables.