Posted by Jerry Stuckle on 10/24/09 11:42
Tyxod wrote:
> The "shuffle" thing does the work but produces an array with 58
> elements. And it works a lot faster than the recursive thing (it
> matters if the function is used more than a few times in a script).
>
> But if you need just 13 (or anything else <>58) items in the array the
> recursive function is really the only sane way to go.
>
> (of course one could "shuffle($randomstuff);" and then pick up the
> first 13 items from the resulted array, but I really dont like doing
> that)
>
Why not?
1. It's much clearer than the recursive code
2. It's faster than the recursive code
If course - it does use 156 more bytes than the recursive solution. But
the parser will probably need more than this just to handle the extra
code anyway.
Sometimes saving a few bytes just isn't worth it!
--
==================
Remove the "x" from my email address
Jerry Stuckle
JDS Computer Training Corp.
jstucklex@attglobal.net
==================
Navigation:
[Reply to this message]
|