I found this snippet of code online and I was wondering what it does:
$k[$i] = ord($key{$i}) & 0x1F;
I know that ord() returns an ASCII value, but I’m unclear on what the curly brackets do $key{$i} and also what this does & 0x1F.
Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.
Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.
Lost your password? Please enter your email address. You will receive a link and will create a new password via email.
Please briefly explain why you feel this question should be reported.
Please briefly explain why you feel this answer should be reported.
Please briefly explain why you feel this user should be reported.
That’s not an array syntax. It’s for accessing single characters from strings only. The index must be numeric.
It’s briefly mentioned here in the info box: http://www.php.net/manual/en/language.types.string.php#language.types.string.substr
Also, it’s officially declared deprecated.It has been on and off supposed deprecation in the manual, but is still very valid, if uncommon, syntax.The
& 0x1Fis a bit-wise AND. In this case it limits the decimal values to 0 till 31.