I'm confused about the term Ordinal value of a character or a string in php documentation. Can somebody tell me what exactly an ordinal value is?
This is most appropriate when comparing strings that are generated programmatically or when comparing case-sensitive resources such as passwords. The Ordinal property actually returns an instance of an anonymous class derived from the StringComparer class. Gets the value associated with the specified key.
The Ordinal Value of a character is nothing but the numeric location of a character. Not the answer you're looking for? Browse other questions tagged php or ask your own question.
Ordinal data are categorical (non-numeric) but may use numbers as labels. Ordinal data are always placed into some kind of hierarchy or order (hence the name ‘ordinal’—a good tip for remembering what makes it unique!) While ordinal data are always ranked, the values do not have an even distribution.
While nominal and ordinal variables are categorical, interval and ratio variables are quantitative. Nominal data differs from ordinal data because it cannot be ranked in an order.
One "character" in PHP is one byte. Note that this is misleading for multi-byte characters, in which one character (say "漢") is encoded in multiple bytes. Anyway though, a byte is 8 bits and can represent a number between 0 and 255. The ordinal value of a character byte is simply this numerical value.
ord('a') -> 97
Read http://kunststube.net/encoding if you need more background information about bytes/characters/encodings.
Ordinal value is Nothing but the ASCII value of a character And as we know every character takes one byte i.e. 8 bits and every bit can have either 0 or 1 as the possible value so every bit can have 2 values thus 8 positions can have power(2,8) = 256 combinations and every combination resembles 1 character like
00000000 => Null(0)
00010000 => Space(32)
(65 - 91) in Ascii => a-z
(97 - 122) in Ascii => (A-Z)
and (48 - 57) in Ascii => (0 - 9)
other combinations are assigned to other special chacater.
PHP have an inbuilt Function ord('a') which takes character as an argument and returns its ascii value i.e. 65 in this case
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With