fork download
  1. <?php
  2.  
  3. $data = Array(
  4. 'sites' => Array(
  5. 0 => '',
  6. 1 => '5 Estacao',
  7. 2 => '3 Estacao',
  8. 3 => '4 Estacao',
  9. 4 => '1 Estacao',
  10. 5 => '2 Estacao',
  11. ),
  12. 'IPs' => Array(
  13. 0 => '',
  14. 1 => '172.168.0.15',
  15. 2 => '172.168.0.13',
  16. 3 => '172.168.0.14',
  17. 4 => '172.168.0.11',
  18. 5 => '172.168.0.12',
  19. )
  20. );
  21.  
  22. function order ($arr)
  23. {
  24. $arr = array_map(null, $arr["sites"], $arr["IPs"]);
  25.  
  26. usort($arr, function ($a, $b) {
  27. return strcmp($a[0], $b[0]);
  28. });
  29.  
  30. return [
  31. "sites" => array_column($arr, 0),
  32. "IPs" => array_column($arr, 1)
  33. ];
  34. }
  35.  
  36. print_r(order($data));
Success #stdin #stdout 0.01s 82880KB
stdin
Standard input is empty
stdout
Array
(
    [sites] => Array
        (
            [0] => 
            [1] => 1 Estacao
            [2] => 2 Estacao
            [3] => 3 Estacao
            [4] => 4 Estacao
            [5] => 5 Estacao
        )

    [IPs] => Array
        (
            [0] => 
            [1] => 172.168.0.11
            [2] => 172.168.0.12
            [3] => 172.168.0.13
            [4] => 172.168.0.14
            [5] => 172.168.0.15
        )

)