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