<?php
//moving zeros to the enda and remainig orders of remaining elements
//input:[0,1,0,3,12]=>output:[1,3,12,0,0]
function moveZeroes(&$nums) {
print_r($nums);
$count = count($nums); //counting array elements
for ($i = 0; $i < $count; $i++) {
//counting loops while situated in array
if ($nums[$i] == 0) {
//checking if number is 0
unset($nums[$i]); //unsetting this number and moving to the end
$nums[] = 0;
}
}
}
$array = [0, 1, 0, 3, 12];
moveZeroes($array);
print_r($array);