PHP loop make variable available in the next loop -


i have loop (just sample, many vars missing):

foreach($inserts $insert) {  $insert_update = 'insert etc.. set etc..'; // returns last inserted id  $insertedids[] = array($tables[$tbl]['owner'] => $insert_update); } 

now see $insertedids[] getting in array new inserted ids. problem on next $inserts loop i'll need $insertedids[] available other variables of loop, need last inserted id. problem on next loop variable not recognized , returns errors.

how can make $insertedids[] available on each next loop after first loop?

i tried declaring $insertedids[] global after foreach no luck.

thanks suggestion

try may it'll you:

$insertedids=array(); foreach($inserts $insert) {  $insert_update = 'insert etc.. set etc..'; // returns last inserted id  $insertedids[] = array($tables[$tbl]['owner'] => $insert_update); } 

now able access $insertedids


Comments

Popular posts from this blog

php - Calling a template part from a post -

Firefox SVG shape not printing when it has stroke -

How to mention the localhost in android -