L PROTECTED]]
Sent: 04 December 2001 15:22
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
delim
=
Darren Gamble
Planner, Regional Services
Shaw Cablesystems 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'; P
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];
}
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
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 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 :(
6 matches
Mail list logo