Re: [PHP] 2 dimensional array processing

2005-01-11 Thread Richard Lynch
Brent Baisley wrote: > foreach($insert as $table => $fields) { > $fieldList = array_keys($fields); > $fieldNames = implode(',', $fieldList); > $fieldValues = '"'.implode('","', $fields).'"'; > echo 'insert into '.$table.' ('.$fieldNames.') values > ('.$fieldValues.')'; > } >

Re: [PHP] 2 dimensional array processing

2005-01-11 Thread Brent Baisley
A, I was wondering why your variable was named insert. Anyway, that's easy too. foreach($insert as $table => $fields) { $fieldList = array_keys($fields); $fieldNames = implode(',', $fieldList); $fieldValues = '"'.implode('","', $fields).'"'; echo 'insert into '.$table.' ('.$fieldNames.') va

Re: [PHP] 2 dimensional array processing

2005-01-11 Thread Benjamin Edwards
Ok - looking at what you did I cant see any diference apart from turning a serious updated into a single update. This is usefull if I want to do an update but I actualy want an insert (the update was just used for this example). I actualy want to do an insert so i'me thinking the following would

Re: [PHP] 2 dimensional array processing

2005-01-11 Thread Brent Baisley
You've created a 2x2 array, not a 1x4, which might be confusing you: tab2 ["fields1"] ["fields5"] tab1 ["fields2"] ["fields7"] You almost have it, you just need to set your loop up to handle unlimited field/value pairs in your array. One option is to structure your loop like this: foreach ($inse

[PHP] 2 dimensional array processing

2005-01-11 Thread Benjamin Edwards
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 fir