Path: csiph.com!v102.xanadu-bbs.net!xanadu-bbs.net!feeder.erje.net!eu.feeder.erje.net!newsreader4.netcologne.de!news.netcologne.de!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail Content-Type: text/plain; charset="ISO-8859-1" Message-ID: <4900575.IOLIoYm6Jl@PointedEars.de> From: Thomas 'PointedEars' Lahn Reply-To: Thomas 'PointedEars' Lahn Organization: PointedEars Software (PES) Date: Sat, 15 Mar 2014 23:14:17 +0100 User-Agent: KNode/4.11.5 Content-Transfer-Encoding: 7Bit X-Face: %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&. <2311625.YxiY5vK2W4@PointedEars.de> <0.6b9d1a51aaf973162356.20140315213216GMT.8761nf5esf.fsf@bsb.me.uk> MIME-Version: 1.0 Lines: 49 NNTP-Posting-Date: 15 Mar 2014 23:14:20 CET NNTP-Posting-Host: 20ac1301.newsspool2.arcor-online.net X-Trace: DXC=TgL@Y;A>k^5lIh70@DZm8W4\YJN Thomas 'PointedEars' Lahn writes: >> Daniel Pitts wrote: >>> for ($x = 1; $x < 40; ++$x) { >>> $ayr[$x] = rand(60, 69); >>> } >>> >>> So much simpler, more efficient, and actually correct. >> >> No, this will produce an array of only 39 elements, assuming there was >> not already one. This can be easily fixed, of course. >> >> Still, >> >> $keys = range(1, 40); >> $ayr = array_combine($keys, array_map(function () { >> return rand(60, 69); >> }, $keys))); >> >> is much more elegant :) > > Yes, but it's a shame about the extra ')'. Ah, yes, no idea how that got in there. Should have been $keys = range(1, 40); $ayr = array_combine($keys, array_map(function () { return rand(60, 69); }, $keys)); > I think > > $ayr = array_map(function () { return rand(60, 69); }, > array_fill(1, 40, null)); > > is a little simpler. ACK. Actually, I had experimented with array_fill() but, strangely enough, I overlooked this possibility. (I had posted something similar with regard to letters not long ago.) PointedEars -- Prototype.js was written by people who don't know javascript for people who don't know javascript. People who don't know javascript are not the best source of advice on designing systems that use javascript. -- Richard Cornford, cljs,