Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #11779
| Path | csiph.com!usenet.pasdenom.info!weretis.net!feeder1.news.weretis.net!feeder.erje.net!eu.feeder.erje.net!newsfeed.fsmpi.rwth-aachen.de!npeer.de.kpn-eurorings.net!npeer-ng0.de.kpn-eurorings.net!newsfeed.arcor.de!newsspool3.arcor-online.net!news.arcor.de.POSTED!not-for-mail |
|---|---|
| Content-Type | text/plain; charset="UTF-8" |
| Message-ID | <3677958.dk8vouHeg2@PointedEars.de> (permalink) |
| From | Thomas 'PointedEars' Lahn <PointedEars@web.de> |
| Reply-To | Thomas 'PointedEars' Lahn <php@PointedEars.de> |
| Organization | PointedEars Software (PES) |
| Date | Fri, 15 Nov 2013 15:11:48 +0100 |
| User-Agent | KNode/4.10.5 |
| Content-Transfer-Encoding | 8Bit |
| X-Face | %i>XG-yXR'\"2P/C_aO%~;2o~?g0pPKmbOw^=NT`tprDEf++D.m7"}HW6.#=U:?2GGctkL,f89@H46O$ASoW&?s}.k+&.<b';Md8`dH6iqhT)6C^.Px|[=M@7=Ik[_w<%n1Up"LPQNu2m8|L!/3iby{-]A+#YE}Kl{Cw$\U!kD%K}\2jz"QQP6Uqr],./"?;=4v |
| Face | iVBORw0KGgoAAAANSUhEUgAAADAAAAAwBAMAAAClLOS0AAAAGFBMVEXTxa4RFk5dUWANED8PFEfy7+MGBiW+n3ZNF/QuAAACaElEQVQ4jVXUwVOcMBQG8Dc7Rc4PUntdWV2uxjDpGaGeozOp1woar4jd5t/v9wLstMwsA/ntlxdCAgUc1hjTc9/JCZfGoo3wG3HdmdAWrIJRHe7GM/TmpY5VFefuVcAkkPbLIaN8rmPmjloyZxgyR3GuJ4K0AGtJ2htz8o7yqikm759fldQXaMpbDzjKAG+8v+AugVTOPO5DOjLvGtUYQwh0CPjnVMyGd+8/GfUB5nLKJDD2aLDh5HYyMDJGDwQIo2ZmZcKbowNmAdB/AzyFhrmF2MHRb0QJJfaAnwGB6orZhoykLzJtGwF/xpYxI1dswomiUj3gTuAIqCn/4C7cULwGNBtwMTk3Y4LfKB5YUaOKBKYtpplm7u0vip8tU1NWWyI/7XdcSuIDoMt6rVHMWT0DbjHPGqDqZVSa6zleLcUTcIKLoMv3ueJluALtAo9B302zPPlrtiVScRdCjXvVh3e3JpYa/jjkuC9N+LrBMlz/eAN4eQijX2EdLo6c5tGGHwLyHFtXk89dDGHwCVhG9T0S/j55AhRZgkMCmUQXJ49TnS1wnQDvw0eAh9ICeMmEFbCnPMFzjAvsWoEWEFdYEx+S0MoUZ1gT1wId8+AF3Bl2OoEu906AUHx5VLw/gXYg/x84loOah/2UYNrgiwSwGO7RfUzVBbx/kgpckumGOi6QirtD6gkLTitbnxNol47S2jVc2vsN5kPqaAHT8uUdAJM4v/DanjYOwmUjWznGfwB7sGtAtor5BgofDuzaRj4kSQAqDakTsKORa3Q3xKi3gE1fhl71KRMqrdZ2AWNNg/YOhQyrVBnb+i+nEg4bsDA+egAAAABJRU5ErkJggg== |
| Subject | Re: how change an array |
| Newsgroups | comp.lang.php |
| References | <w24nnxz85z5i$.108876h4m2t3t.dlg@40tude.net> <l6562m$867$1@dont-email.me> |
| MIME-Version | 1.0 |
| Lines | 45 |
| NNTP-Posting-Date | 15 Nov 2013 15:12:14 CET |
| NNTP-Posting-Host | c39cc495.newsspool1.arcor-online.net |
| X-Trace | DXC=_8;Rhm63N\XAX0F2i><W:Sic==]BZ:af^4Fo<]lROoRQnkgeX?EC@@P:HSIQ^WeSTRDZm8W4\YJN\YUVHKH;GI^Wk1;Nc]Ncg]WkoA4EESH:2\ |
| X-Complaints-To | usenet-abuse@arcor.de |
| Xref | csiph.com comp.lang.php:11779 |
Show key headers only | View raw
Norman Peelman wrote:
> On 11/15/2013 07:23 AM, nawfer wrote:
>> with this
>> 1)
>> foreach($models as $md)
>> {$articles[] = array($md->id,$md->name);}
>>
>> I have
>> Array ([0] => Array ([0] => 4 [1] => Libri )
>> [1] => Array ( [0] => 2 [1] => Riviste )
>> [2] => Array ( [0] => 1 [1] => Giornali ) )
>>
>>
>> how can change code 1) for have this:
>>
>> Array ( [4] => Libri
>> [2] => Riviste
>> [1] => Giornali )
>>
>
> foreach($models as $md)
> {
> $articles[$md->id] = $md->name;
> }
>
> or (if above doesn't work)
> foreach($models as $md)
> {
> $tmp = $md->id;
> $articles[$tmp] = $md->name;
> }
Under which circumstances would the second code work, but not the first one?
BTW: You should be writing “foreach (” (and “if (”, “switch (” etc.) so that
it is not mistaken by the reader for a function call.
PointedEars
--
> If you get a bunch of authors […] that state the same "best practices"
> in any programming language, then you can bet who is wrong or right...
Not with javascript. Nonsense propagates like wildfire in this field.
-- Richard Cornford, comp.lang.javascript, 2011-11-14
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
how change an array nawfer <novalidsforspam@alt.al> - 2013-11-15 13:23 +0100
Re: how change an array Jerry Stuckle <jstucklex@attglobal.net> - 2013-11-15 07:47 -0500
Re: how change an array Norman Peelman <npeelman@cfl.rr.com> - 2013-11-15 08:03 -0500
Re: how change an array Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-11-15 15:11 +0100
Re: how change an array nawfer <novalidsforspam@alt.al> - 2013-11-15 17:32 +0100
Re: how change an array Denis McMahon <denismfmcmahon@gmail.com> - 2013-11-15 17:33 +0000
csiph-web