Looking up, deleting and inserting array values

[Date Prev][Date Next][Thread Prev][Thread Next][Date Index][Thread Index]

 



Hi,
I'm trying to do something that I know works when you build an array like a
"map" with elements and values. One of the problems with this is that I only
get out the values from the array from the last row. And the other problem
is it looks like I can't delete desired values within the array. Is anyone
able to tell me if it's really possible? And if it is, how?
A snip of my code follows bellow:

($$row[3] contains single values that apear in the rows and are decleared
higher up on the page)

    while($row=mysql_fetch_array($result)) {
    
        // If var based named as value in $row[3]
        if ($$row[3]) {
    
            // Splits keys and values
            foreach($$row[3] AS $key => $value) {
            
                // If $value is the same as $row[2]
                if ($value == $row[2]) {
                   
                    // Sum old value within the array with the new value
                    $new_value = $value+$row[2];

                    // Delete the old value from the array
                    unset($$row[3][$key]);
                
                    // Insert the new value
                    array_push($$row[3], $new_value);
                   
                }
            
            }
        
        }
    
    }

Thanks in advance // Jonas
(Yes, I try to read the manual - but it's not allways good enough for me)

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


[Index of Archives]     [PHP Home]     [Apache Users]     [PHP on Windows]     [Kernel Newbies]     [PHP Install]     [PHP Classes]     [Pear]     [Postgresql]     [Postgresql PHP]     [PHP on Windows]     [PHP Database Programming]     [PHP SOAP]

  Powered by Linux