Guest User

Untitled

a guest
Apr 26th, 2018
64
0
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
PHP 0.45 KB | None | 0 0
  1. <?php
  2.  
  3. // Original Arrays
  4. $a = array(0,1,2,3,4,5);
  5. $b = array(6,7,8,9,10);
  6.  
  7. // Create an empty new array
  8. $ab = array();
  9.  
  10. // Add all the values from array a to the new array
  11. foreach ($a as $value) {
  12.    
  13.     $ab[] = $value;
  14.  
  15. }
  16.  
  17. // Add all the values from array b to the new array
  18. foreach ($b as $value) {
  19.  
  20.     $ab[] = $value;
  21.  
  22. }
  23.  
  24. // Sort the array in ASC order
  25. sort($ab);
  26.  
  27. // Print the new array
  28. echo '<pre>';
  29. print_r($ab);
  30. echo '</pre>';
Add Comment
Please, Sign In to add comment