Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #11778
| From | Norman Peelman <npeelman@cfl.rr.com> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: how change an array |
| Date | 2013-11-15 08:03 -0500 |
| Organization | A noiseless patient Spider |
| Message-ID | <l6562m$867$1@dont-email.me> (permalink) |
| References | <w24nnxz85z5i$.108876h4m2t3t.dlg@40tude.net> |
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;
}
--
Norman
Registered Linux user #461062
-Have you been to www.php.net yet?-
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