fork download
  1. <?php
  2.  
  3. $flats[0] = array("rooms"=>"3", "price"=>"1500", "url"=>"http://content-available-to-author-only.com");
  4. $flats[1] = array("rooms"=>"1", "price"=>"300", "url"=>"http://content-available-to-author-only.com");
  5. $flats[2] = array("rooms"=>"2", "price"=>"300", "url"=>"http://content-available-to-author-only.com");
  6. $flats[3] = array("rooms"=>"3", "price"=>"700", "url"=>"http://content-available-to-author-only.com");
  7. $flats[4] = array("rooms"=>"2", "price"=>"800", "url"=>"http://content-available-to-author-only.com");
  8.  
  9. function cmp($a, $b) {
  10. if ($a["price"] == $b["price"]) {
  11. return 0;
  12. }
  13. return ($a["price"] < $b["price"]) ? -1 : 1;
  14. }
  15.  
  16. uasort($flats, "cmp");
  17. print_r($flats);
Success #stdin #stdout 0.03s 52432KB
stdin
Standard input is empty
stdout
Array
(
    [1] => Array
        (
            [rooms] => 1
            [price] => 300
            [url] => http://content-available-to-author-only.com
        )

    [2] => Array
        (
            [rooms] => 2
            [price] => 300
            [url] => http://content-available-to-author-only.com
        )

    [3] => Array
        (
            [rooms] => 3
            [price] => 700
            [url] => http://content-available-to-author-only.com
        )

    [4] => Array
        (
            [rooms] => 2
            [price] => 800
            [url] => http://content-available-to-author-only.com
        )

    [0] => Array
        (
            [rooms] => 3
            [price] => 1500
            [url] => http://content-available-to-author-only.com
        )

)