The task is to delete a column or row in a two-dimensional array completely, so that the next one would be replaced and the length would be reduced by 1. I tried array_splice(); without specifying replacement but the length of the array is not reduced, and when using sort(); the data does not go to the beginning (up if the line), but to the end - down, after which, when outputting, the first line is the empty line.
Is there some working way to properly trim an array?
Now I do this (input array - unset - output):
for ($i=0; $i<10; $i++) { for ($j=0; $j<10; $j++) { $hh[$i][$j]="$i$j"; echo $hh[$i][$j]." "; } echo "<br>"; } //array_splice($hh[1],0,10); unset($hh[5]); for ($i=0; $i<10; $i++) { for ($j=0; $j<10; $j++) { echo $hh[$i][$j]." "; } echo "<br>"; } Conclusion:
00 01 02 03 04 05 06 07 08 09 10 11 12 13 14 15 16 17 18 19 20 21 22 23 24 25 26 27 28 29 30 31 32 33 34 35 36 37 38 39 40 41 42 43 44 45 46 47 48 49 60 61 62 63 64 65 66 67 68 69 70 71 72 73 74 75 76 77 78 79 80 81 82 83 84 85 86 87 88 89 90 91 92 93 94 95 96 97 98 99 As a result, the problem is the same, the empty string on the same index. Initially, array_splice($hh[5],0,10); .