In most cases, using the same variable as a key or value both by the inner and outer ‘foreach’ loops either is an error or may result in an error in the future.