If I create the following 2 dimensional associative array:- $insert["tab2"]["fields1"] = "value1"; $insert["tab1"]["fields2"] = "value2"; $insert["tab2"]["fields5"] = "value3"; $insert["tab1"]["fields7"] = "value4"; how do I do 2 levels of nested loop with the first level looping through the first level of the array and the second nesting through the second. something like:- foreach( $insert as $table => $fields ) { foreatch( $fields as $field => $value ) { echo "update $table set $field = $value"; } } Regards, Ben