Reputation: 39324
I need to use the PHP function strtolower($str)
to put a large string in all-lower-case. Since the string is large, I would have liked if it could be taken as a reference and operated on. For example (though this doesn't work):
I wanted to do:
$myLargeString = PopulateString();
strtolower(&$myLargeString);
instead of:
$myLargeString = PopulateString();
$myLargeString = strtolower($myLargeString);
is there any trick that would let me lower-case a string by reference to save some speed, or maybe another function I should be looking at? I'm not particularly strong in PHP so I'm not sure what to look for.
Upvotes: 2
Views: 79
Reputation: 33457
You cannot force a non-reference taking function to take a reference. In fact, specifying that it's pass by reference at call time is now deprecated (http://php.net/manual/en/language.references.pass.php).
You could of course write your own implementation of strtolower(). As it would be in PHP and the strtolower implementation is in C, I'm not sure how much performance you could actually gain. I suppose it would depend on how long the string is.
Upvotes: 2