PHP.net‘s documentation on the range function is a little lacking. These functions produce unexpected (to me anyways) results when given character ranges.
$m = range('A','z');
print_r($m);
$m = range('~','"');
print_r($m);
I’m looking for a reference that might explicitly define its behavior.
The issue is that range treats its arguments like integers, and if you give it a single character it will convert it to its ASCII character code.
In the first case, you’re getting all characters between character ‘A’ (integer 65) and character ‘z’ (integer 122). This is expected behavior for those of us coming from a C (or C-like language) background.
This is one of the rare cases where PHP converts single characters to their ASCII codes rather than parsing the string as integer the way it does normally. Most of the PHP documentation is better at telling you when to expect this. strpos for example, notes:
The documentation for range is strangely quiet about it.