How can I insert values into a multidimensional array in php? I need to add more and more rows to array using a while loop.
Here is my code:
$size=10;
$p=0;
while($p<$size)
{
$myarray = array(
array("number"=>$data[$p],"data"=>$kkk[1],"status"=>"A"),
array("number"=>$data[$p],"data"=>$kkk[1],"status"=>"A"));
// Each time the loop executes, I need to add more array to myarray.
$p++;
}
for($i=0;$<=$p:$i++)loop inside yourwhileloop.$myarray[] = array( ... );. Might need to initialize$myarray = array();outside of the loop, beforehand.