arrays - PHP sort numbers all zero without changing index -
It should be like this and will not affect the index ... when there is no need to sort all the zeros ... and when I will not have any other result with input zero Edit When I used KSert (this) the result is ... when I input 0, 2, 1 and this is the ordinary code is an output bug What I want is when I put 0,0,0,1 and can not change the key because this is the same ... Then another input is 0,2,1, 3 use AORT (arrival time []) is not correct. How can all this recover when I keep everyone at zero? The display is:
array ([4] => [[3] => 0 [2] => 0 [1] => [0] = & Gt; 0)
Array ([0] => 0 [1] => [0] [2] = 0 [3] => 0 [4] => 0) < / Code>
array ([0] => 0 [2] => 0 [1] = & gt; 0 [3] => 1 [4] => 2) Can anyone else solve?
& lt; Php $ test = array (0,2,1); Ksort ($ test); Echo "& lt; east & gt;"; Print_r ($ test); Echo "& lt; / pre & gt;"; ? & Gt;
array ([0] => 0 [1] => 2 [2] => 1 )
Array ([0] => 0 [1] => [0] [2] = 0 [3] => 0)
array ([0] => 0 [2] => 1 [1] => 2 [3 ] = & Gt; 3)
ksort () function to sort your arrays with their key.
Comments
Post a Comment