To: PHP List; 'Mike Eheler'
Subject: RE: [PHP] Multidimensional array construction
Good day,
Thanks to all who replied.
This isn't quite what I needed, though. I _have_ the array (or
delimited
list would do, too). What I need to do is _CREATE_
GP
630 - 3rd Avenue SW
Calgary, Alberta, Canada
T2P 4L4
(403) 781-4948
-Original Message-
From: Mike Eheler [mailto:[EMAIL PROTECTED]]
Sent: Monday, December 03, 2001 5:30 PM
To: Martin Towell
Cc: 'Darren Gamble'; PHP List
Subject: Re: [PHP] Multidimensional array construction
I did
I was thinking that you could use a pointer to var, eg:
$var = 'myarray[foo][bar][red][apple]';
// this would obviously be created dynamically, hard coded for testing
$$var = $some_value1;
echo $myarray[foo][bar][red][apple];
but when I tried it, it didn't work :(
looks like
This might be interesting ...
The function extract() allows you to extract all values from an array
and prefix them with a specified string. What I didn't know until
just a second ago was that you can supply a function as a string, so
...
$my_array = array(a,b,c,d,array(a,b,c,d));
$i = 1;
oops. That's not correct. I wish it was though! ;)
This might be interesting ...
The function extract() allows you to extract all values from an
array and prefix them with a specified string. What I didn't know
until just a second ago was that you can supply a function as a
string, so ...
I did something like this recently. Here's how I did it:
$some_value1 = 'Hello World';
$myarray['foo']['bar']['green']['apple'] = $some_value1;
function get_opt($arr, $keys,$sep=':') {
$var = $arr;
$tmp = split($sep,$keys);
foreach ($tmp as $k = $v) {
$var = $var[$v];
}
6 matches
Mail list logo