Jonas Rosling wrote:
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]) {

if (${$row[3]}) {

// i.e. help php to figure out how to exactly what you mean
// with curlie braces.

// the for ease of viewing make a reference:

        $myArr =& ${$row[3]};
// Splits keys and values
            foreach($$row[] AS $key => $value) {

        foreach($myArr 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]);

                unset($myArr[$key]); // unset(${$row[3]}[$key]);

// Insert the new value
                    array_push($$row[3], $new_value);

                $myArr[] = $newValue;

} } } }

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

Reply via email to