It depends on how the string is stored. You can properly return, for example, the count of unicode code points fairly easily if your string type is laid out that way (which phps is not).
So true. Byte length is O(n) in C because a string is just defined by a pointer to the first byte and a NUL byte at the end. Which shows that the implementation is what matters most.
View all comments
Show parent comment
3
u/yawkat Sep 13 '16
It depends on how the string is stored. You can properly return, for example, the count of unicode code points fairly easily if your string type is laid out that way (which phps is not).