Advertisement
Achilles

How to remember , What sort function doing ( php )

Jul 13th, 2013
91
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
text 0.58 KB | None | 0 0
  1. <?php
  2.  
  3. $soups = array (
  4. 'Amiche' => 'Tomhaar',
  5. 'Monday' => 'Clam Chowder',
  6. 'Tuesday' => 'White Chicken Chili',
  7. 'Wednesday' => 'Vegetarian'
  8. );
  9.  
  10. $soups2 = array (
  11. 'Thursday' => 'Chicken Noodle',
  12. 'Friday' => 'Tomato',
  13. 'Saturday' => 'Cream of Broccoli'
  14. );
  15.  
  16. /*
  17.  
  18. $arr = $soups + $soups2;
  19.  
  20. var_dump("arr" , $arr);
  21.  
  22. */
  23.  
  24. $arr = array(4 , 1 , 9 ,-1 , 5);
  25.  
  26. // Read as value se reverse sort preserve key values
  27. arsort($soups);
  28.  
  29. var_dump($soups);
  30.  
  31. //Read as key se reverse sort , preserve key values
  32. krsort($soups);
  33.  
  34. var_dump($soups);
Advertisement
Add Comment
Please, Sign In to add comment
Advertisement