Guest User

Untitled

a guest
Mar 13th, 2017
55
Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. <?php
  2. error_reporting(-1);
  3.  
  4. $arr = [
  5.     'African elephant',
  6.     'Spotted hyena',
  7.     'Snow leopard',
  8. ];
  9.  
  10. $new_arr2 = [];
  11. $new_arr3 = [];
  12.  
  13. $final_array = [];
  14.  
  15. foreach($arr as $k){
  16.     $new_arr = explode(' ', $k);
  17.     array_push($new_arr2, $new_arr[1]);
  18.     array_push($new_arr3, $new_arr[0]);
  19.    
  20. }
  21.  
  22.  
  23. for($i = 0; $i < count($new_arr2); $i++){
  24.     if (!in_array($new_arr2[$i], $final_array) || !in_array($new_arr3[$i], $final_array)) {
  25.         $final_array[] = $new_arr3[rand(0, count($new_arr2) -1)] . ' ';
  26.         $final_array[] = $new_arr2[rand(0, count($new_arr3) -1)] . '+';
  27.     }
  28. }
  29.  
  30. echo '<pre>';
  31. var_dump($final_array);
  32. echo '</pre>';
RAW Paste Data