Php Reset Array After Foreach Javascript Mdn For Loop