Свежайшие Пирожки от CakePHP по-русски

Полнейшее руководство CakePHP 1.2 на русском языке, горячие новости и полезные статьи

merge

array Set::merge ($arr1, $arr2=null)

This function can be thought of as a hybrid between PHP's array_merge and array_merge_recursive. The difference to the two is that if an array key contains another array then the function behaves recursive (unlike array_merge) but does not do if for keys containing strings (unlike array_merge_recursive). See the unit test for more information.

This function will work with an unlimited amount of arguments and typecasts non-array parameters into arrays.

Простой текст
  1. $arry1 = array(
  2. array(
  3. 'id' => '48c2570e-dfa8-4c32-a35e-0d71cbdd56cb',
  4. 'name' => 'mysql raleigh-workshop-08 < 2008-09-05.sql ',
  5. 'description' => 'Importing an sql dump'
  6. ),
  7. array(
  8. 'id' => '48c257a8-cf7c-4af2-ac2f-114ecbdd56cb',
  9. 'name' => 'pbpaste | grep -i Unpaid | pbcopy',
  10. 'description' => 'Remove all lines that say "Unpaid".',
  11. )
  12. );
  13. $arry2 = 4;
  14. $arry3 = "This is a String";
  15. $arry3 = array(0=>"test array", "cats"=>"dogs");
  16. $res = Set::merge($arry1, $arry2, $arry3);
  17. /* $res now looks like:
  18. Array
  19. (
  20. [0] => Array
  21. (
  22. [id] => 48c2570e-dfa8-4c32-a35e-0d71cbdd56cb
  23. [name] => mysql raleigh-workshop-08 < 2008-09-05.sql
  24. [description] => Importing an sql dump
  25. )
  26. [1] => Array
  27. (
  28. [id] => 48c257a8-cf7c-4af2-ac2f-114ecbdd56cb
  29. [name] => pbpaste | grep -i Unpaid | pbcopy
  30. [description] => Remove all lines that say "Unpaid".
  31. )
  32. [2] => 4
  33. [3] => test array
  34. [cats] => dogs
  35. )
  36. */