SHARE
TWEET

Untitled

a guest Aug 18th, 2019 61 Never
Not a member of Pastebin yet? Sign Up, it unlocks many cool features!
  1. function rew($arr){
  2. //Берем длинну массива
  3. $len_array = count($arr);
  4. //Берем ключи массива
  5. $keys = array_keys($arr);
  6. //Берем значения массива
  7. $values = array_values($arr);
  8. //Массив где будут новые значения
  9. $new_values = array();
  10. //Переворачиваем массив
  11. for($i = $len_array-1; $i >= 0; $i--){
  12. $new_values [] = $values[$i];
  13. }
  14. //Возвращаем
  15. return array_combine($keys, $new_values);
  16. }
  17.  
  18. //Тестовый массив
  19. $H = array('a'=>'a', 'b'=>'b', 'c'=>'c', 'd'=>'d');
  20. //Запуск теста
  21. $eee = rew($H);
  22. foreach ($eee as $key=>$value){
  23. echo "$key - $value <br>";
  24. }
RAW Paste Data
We use cookies for various purposes including analytics. By continuing to use Pastebin, you agree to our use of cookies as described in the Cookies Policy. OK, I Understand
 
Top