Groups | Search | Server Info | Keyboard shortcuts | Login | Register [http] [https] [nntp] [nntps]


Groups > comp.lang.php > #12329

Re: foreach problem part two

From Norman Peelman <npeelman@cfl.rr.com>
Newsgroups comp.lang.php
Subject Re: foreach problem part two
Date 2013-12-20 07:11 -0500
Organization A noiseless patient Spider
Message-ID <l91c4q$ikt$1@dont-email.me> (permalink)
References <oib4w8z2sr5y$.15xxzxjds0xb0$.dlg@40tude.net> <XnsA29BB28C4C683dougmilmaccom@78.46.70.116> <y1yigdragnyw$.c2kv48q50osj.dlg@40tude.net> <52b398d2$0$9503$9b4e6d93@newsspool1.arcor-online.net> <t6ds31so68b7.1s80a7lxre6po$.dlg@40tude.net>

Show all headers | View raw


On 12/19/2013 11:05 PM, richard wrote:
> On Fri, 20 Dec 2013 02:09:46 +0100, Christoph Michael Becker wrote:
>
>> richard wrote:
>>
>>> 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.
>>
>> Nonsense.  PHP has only one array type.[1]
>>
>>> While (){}. however works and could care less which is used.
>>
>> Assume, you have an array:
>>
>>    $array = array('one', 'two', 'three');
>>
>> Now you want to echo its elements in order.  What is simpler and more
>> readable?
>>
>>    $i = 0;
>>    while ($i < count($array)) {
>>      echo $array[$i];
>>    }
>>
>> or
>>
>>    foreach ($array as $element) {
>>      echo $element;
>>    }
>>
>> Additionally, the foreach loop is most likely faster.
>>
>> [1] <http://www.php.net/manual/en/language.types.array.php>
>
> As you and others so kindly keep repeating, RTFM!
>
> $array[0][0]="data"
>
> Is 100% valid!
>
> In the arrays manual, it shows the use of bracketed arrays several times.
> So why don't you tell them they are wrong?
>


   Then maybe you should read it again, specifically "Creating/modifying 
with square bracket syntax". That tells you why it isn't working.

However:

$year = "60";
$alist = "art".$year;

$$alist = array(0 => array(0 => "00", 1 => "01"), 1 => array(0 => "10", 
1 => "11"));

...is a small example of what you are trying to do.

-- 
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


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