Changing an array while walking the array?
Posted: Wed Jan 31, 2007 1:26 pm
Hi,
I'm having trouble figuring out how to change an array's elements while walking that array.
What I have tried is this.
I have read that this simply makes a copy of $lead_stage_arr in $stage and as such will not affect the former.
I've also read something about placing & before $stage as such: &stage.
But that did not work. Any ideas how to do this. I will keep looking but thanks in advance for any help that you can give me.
poemind.
I'm having trouble figuring out how to change an array's elements while walking that array.
What I have tried is this.
Code: Select all
foreach( $lead_stage_arr as $stage ){
$query = "SELECT COUNT(*) count FROM leads, leads_cstm WHERE assigned_user_id='".$current_user->id."' AND ".$stage['name']."='1'" ;
$result = $lead->db->query($query);
$row=$lead->db->fetchByAssoc($result);
$stage['value'] = $row['count']; // set array for new_c
}
I've also read something about placing & before $stage as such: &stage.
But that did not work. Any ideas how to do this. I will keep looking but thanks in advance for any help that you can give me.
poemind.