Skip to content
Advertisement

How to populate an array dynamicaly using a loop in PHP?

How to populate an array dynamicaly using a for loop in PHP?

eg: Here is an array…

JavaScript

… and here is the for loop

JavaScript

The array should become

JavaScript

Depending on the $qcount the array should expand. Please help.

Advertisement

Answer

you can initialize array like this

JavaScript

add value using a loop

JavaScript

and after loop, you can check with printing array

JavaScript
User contributions licensed under: CC BY-SA
9 People found this is helpful
Advertisement