4 ms·
PHP's string datatype (in the C code) had a length field in addition to the actual bytes (probably still has), so the idea is not always bad (if most of what yo
by wink 4y ago
PHP's string datatype (in the C code) had a length field in addition to the actual bytes (probably still has), so the idea is not always bad (if most of what you do is string manipulation, so len() is O(1) and not O(n)) but I get your point, that's hidden deep in the language for perf reasons, not in user code :P
- forgetfulness 4y agoNo, that's fine, this is more like the `len()` function being called implicitly if the array is being passed to where a "scalar" value is expected. Like here: sub some_function($) { my $some_var = @_; print("$some_var\n"); } my @arr = (1, 2, 4, 7); some_function(@arr); This prints the length of the array.