Tom,

This seems like what I need exactly, but I am having a bit of trouble getting it to work.

Here is how I have worked around this, but I know there is a 'real' way to do this. Any thoughts? I had to set the variables, or should I just use the variables as ${dra_0} etc.?

// get the values for the default dra from array
while(list($key,$val) = each($r_p_dras)){
        $n = "dra_$key";
        echo $n;
        $$n = $val['dra_id'];
}

$dra_a = "${dra_0}";
$dra_b = "${dra_1}";
$dra_c = "${dra_2}";
$dra_d = "${dra_3}";
$dra_e = "${dra_4}";

On Saturday, March 15, 2003, at 02:08 PM, Tom Rogers wrote:

Hi,

Sunday, March 16, 2003, 4:52:10 AM, you wrote:
CK> Hi all,

CK> I have an array that gives me this when I do:

CK> print_r($my_array);

CK> Array
CK> (
CK>      [0] => Array
CK>          (
CK>              [dra_id] => 5
CK>          )

CK>      [1] => Array
CK>          (
CK>              [dra_id] => 8
CK>          )

CK>      [2] => Array
CK>          (
CK>              [dra_id] => 9
CK>          )

CK> )

CK> using a foreach() I want to create a variable with a unique incremental
CK> name for each of the values.


CK> for example:

CK> $dra_1 = 5;
CK> $dra_2 = 8;
CK> $dra_3 = 9;

CK> How would I do this? A variable that has a variable name based on a
CK> counter in the loop? Not sure the syntax for that.

CK> Thanks
CK> Charles

something like this...

while(list($key,$val) = each($my_array)){
        $n = 'dra_'.$key+1;
        $$n = $val['dra_id'];
}





--
regards,
Tom



--
PHP General Mailing List (http://www.php.net/)
To unsubscribe, visit: http://www.php.net/unsub.php



Reply via email to