Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]
Groups > comp.lang.php > #12323
| From | Arno Welzel <usenet@arnowelzel.de> |
|---|---|
| Newsgroups | comp.lang.php |
| Subject | Re: foreach problem part two |
| Date | 2013-12-20 07:52 +0100 |
| Message-ID | <52B3E919.8020109@arnowelzel.de> (permalink) |
| References | <oib4w8z2sr5y$.15xxzxjds0xb0$.dlg@40tude.net> <XnsA29BB28C4C683dougmilmaccom@78.46.70.116> <y1yigdragnyw$.c2kv48q50osj.dlg@40tude.net> |
richard, 2013-12-20 00:39:
> On Thu, 19 Dec 2013 22:34:24 +0000 (UTC), Doug Miller wrote:
>
>> richard <noreply@example.com> wrote in news:oib4w8z2sr5y$.15xxzxjds0xb0$.dlg@
>> 40tude.net:
>>
>>> <?php
>>> foreach ($aname as $item){
>>> echo $aname[$item][1];
>>> echo " (".$aname[$item][2].")";
>>> }
>>> ?>
>>>
>>> I decided to create a second array that holds only the artist and number of
>>> records.
>>> So why am I getting "invalid argument" with this?
>>
>> Because you don't understand how foreach() works. RTFM.
>
> I did.
> There is a flaw in the works that is not discussed.
> That being, it won't work with brackted arrays.
> Works fine with standard arrays.
Sigh...
There is no thing like "bracketed arrays" or "standard arrays". This is
called one-dimensional and multi-dimensional. And of course foreach()
works fine with every kind of array.
<?php
$myarray = array(
array( 'Apple', 1 ),
array( 'Pie', 2 )
);
foreach($myarray as $item)
{
echo $item[0] . ' - ' . $item[1] . '<br />';
}
?>
You just don't understand it - as usual.
> While (){}. however works and could care less which is used.
As usual. while() needs more code, is slower and is prone to errors.
Really - software development is not your thing. It seems you are
mentally not capable of understanding the principles.
--
Arno Welzel
http://arnowelzel.de
http://de-rec-fahrrad.de
Back to comp.lang.php | Previous | Next — Previous in thread | Next in thread | Find similar | Unroll thread
foreach problem part two richard <noreply@example.com> - 2013-12-19 13:41 -0500
Re: foreach problem part two Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-19 20:00 +0100
Re: foreach problem part two Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-19 19:16 +0000
Re: foreach problem part two The Natural Philosopher <tnp@invalid.invalid> - 2013-12-19 19:21 +0000
Re: foreach problem part two The Natural Philosopher <tnp@invalid.invalid> - 2013-12-19 19:20 +0000
Re: foreach problem part two Evan Platt <evan@theobvious.espphotography.com.invalid> - 2013-12-19 23:07 -0800
Re: foreach problem part two Scott Johnson <noonehome@chalupasworld.com> - 2013-12-20 00:59 -0800
fixed! (was: foreach problem part two) richard <noreply@example.com> - 2013-12-19 16:07 -0500
Re: fixed! (was: foreach problem part two) Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-20 18:48 +0000
Re: foreach problem part two Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-12-19 22:34 +0000
Re: foreach problem part two richard <noreply@example.com> - 2013-12-19 18:39 -0500
Re: foreach problem part two Jerry Stuckle <jstucklex@attglobal.net> - 2013-12-19 19:51 -0500
Re: foreach problem part two Christoph Michael Becker <cmbecker69@arcor.de> - 2013-12-20 02:09 +0100
Re: foreach problem part two richard <noreply@example.com> - 2013-12-19 23:05 -0500
Re: foreach problem part two Richard Damon <Richard@Damon-Family.org> - 2013-12-19 23:37 -0500
Re: foreach problem part two Norman Peelman <npeelman@cfl.rr.com> - 2013-12-20 07:14 -0500
Re: foreach problem part two Thomas 'PointedEars' Lahn <PointedEars@web.de> - 2013-12-20 16:35 +0100
Re: foreach problem part two Norman Peelman <npeelman@cfl.rr.com> - 2013-12-20 07:11 -0500
Re: foreach problem part two Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-12-20 13:17 +0000
Re: foreach problem part two Evan Platt <evan@theobvious.espphotography.com.invalid> - 2013-12-20 09:14 -0800
Re: foreach problem part two Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-20 18:52 +0000
Re: foreach problem part two John Smith <johnsmithjsm@live.com> - 2014-01-06 23:13 -0500
Re: foreach problem part two Christoph Michael Becker <cmbecker69@arcor.de> - 2014-01-07 10:07 +0100
Re: foreach problem part two Doug Miller <doug_at_milmac_dot_com@example.com> - 2013-12-20 03:11 +0000
Re: foreach problem part two Arno Welzel <usenet@arnowelzel.de> - 2013-12-20 07:52 +0100
Re: foreach problem part two Denis McMahon <denismfmcmahon@gmail.com> - 2013-12-20 18:37 +0000
csiph-web