arrays - PHP sort numbers all zero without changing index -


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)   

It should be like this and will not affect the index ... when there is no need to sort all the zeros ...

  Array ([0] => 0 [1] => [0] [2] = 0 [3] => 0 [4] => 0) < / Code>  

and when I will not have any other result with input zero

  array ([0] => 0 [2] => 0 [1] = & gt; 0 [3] => 1 [4] => 2) Can anyone else solve?  

Edit When I used KSert (this) the result is ... when I input 0, 2, 1 and this is the ordinary code

  & lt; Php $ test = array (0,2,1); Ksort ($ test); Echo "& lt; east & gt;"; Print_r ($ test); Echo "& lt; / pre & gt;"; ? & Gt;   

is an output bug

  array ([0] => 0 [1] => 2 [2] => 1 )   

What I want is when I put 0,0,0,1 and can not change the key because this is the same ...

  Array ([0] => 0 [1] => [0] [2] = 0 [3] => 0)   

Then another input is 0,2,1, 3

  array ([0] => 0 [2] => 1 [1] => 2 [3 ] = & Gt; 3)   

use ksort () function to sort your arrays with their key.

Comments

Popular posts from this blog

jasper reports - How to center align barcode using jasperreports and barcode4j -

Verilog Error: output or inout port "Q" must be connected to a structural net expression -

c# - ASP.NET MVC - Attaching an entity of type 'MODELNAME' failed because another entity of the same type already has the same primary key value -