Re: [from internals] Re: ref fix revisited
| From: | Jasper Bryant-Greene | Date: | Tue, 13 Sep 2005 08:11:15 +0000 |
| Subject: | Re: [from internals] Re: ref fix revisited | ||
| References: | 1 2 | Groups: | php.general |
| Request: | Send a blank email to php-general+get-222252@lists.php.net to get a copy of this message | ||
Jochem Maas wrote:
hello Rasmus, sorry to interrupt ... but ... could you possibly spare a moment to explain why the SquirrelMail example you gave is 'dumb' code? (I for one would like to avoid writing dumb code wherever possible, and it looks a lot like I line I could have written!) many thanks and regards, jochem Rasmus Lerdorf wrote: ...I know I'm not Rasmus ... but I thought he already explained it pretty well in the email you quoted. By the way, please don't top-post. array_shift [1] receives its first argument as a reference (and modifies it), but because you're not actually passing a variable here, but actually the result of split(), what exactly is array_shift meant to modify? A better way to write that would be: <?php $value_parts = split('/\w/', trim($value)); $value = strtolower($value_parts[0]); ?> ... which has the advantage of being a bit more readable too. [1] http://php.net/array_shift -- Jasper Bryant-Greene Freelance web developer http://jasper.bryant-greene.name/SquirrelMail has code like this all over the place: $value = strtolower(array_shift(split('/\w/',trim($value))));