when I’m trying to copy an array’s element to another using php
$new=array();
for($i=0;$i<$num;$i+3){
$new[] = $old[$i];
}
it is throwing an error Fatal error: Allowed memory size of 134217728 bytes exhausted (tried to allocate 35 bytes)
I need to copy old‘s element into new by skipping two elements in between (I need 1st, 4th, 7th elements .. skipping 2nd&3rd, 5th&6th, 8th&9th)
suggest me how
update:solved—sry its typo error… its silly but i starred @ my code for 15min and not found my typo error…am copying the code, how i rectified
$new=array();
for($i=0;$i<$num;$i+=3){
$new[] = $vdo[$i];
}
There’s a typo, I believe. Replace
$i+3with$i+=3. You just get into infinite loop and your$newarray grows out of proportion and memory.