Reply to Re: Can't display column of multi-dimensional array

Your name:

Reply:


Posted by Bent Stigsen on 09/19/05 00:19

news@celticbear.com wrote:
> Thanks for the help!
> I went this way:
>
> $a = array(
> array('name' => 'Name', 'value' => $name),
> array('name' => 'Message', 'value' => $msg),
> array('name' => 'Subject', 'value' => $subj)
> );
[snip]

In this case there is no need to use a multidimensional array, as
PHP's arrays are maps, which has many purposes.

For the above, you might as well use:
$a = array(
'Name' => $name),
'Message' => $msg),
'Subject' => $subj)
);

[snip]
> The relationship of the $field, which is the next iteration of the
> array, and the LIST parses the twho columns, right?

You can say that. An important note is that "list" should be used only
when the array is sequently indexed like an ordinary array or vector.
Each "argument"(variable) passed to "list" will given the value of
respectively the 1st(indexed zero), 2nd, 3rd and so forth, value in
the array.
I.e. given the array:
$arr = array('a', 'b', 'c', 7 => 'd');

This:
list($a, $b, $c) = $arr;

is equivalent to:
$a = $arr[0];
$b = $arr[1];
$c = $arr[2];

This:
list($a, $b, $c, $d) = $arr;

will give a warning for undefined index, because there is no $arr[3].


/Bent

[Back to original message]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация