Skip to content

Instantly share code, notes, and snippets.

@kuredev
Created November 18, 2017 09:21
Show Gist options
  • Save kuredev/b193cedf4f7df8efaf40b0ad0873a166 to your computer and use it in GitHub Desktop.
Save kuredev/b193cedf4f7df8efaf40b0ad0873a166 to your computer and use it in GitHub Desktop.
array_reduceの小さなメモ
<?php
function merge(string $str1 = null, string $str2){
$str = $str1.$str2;
return $str;
}
$arr = array("str1", "str2", "str3", "str4");
echo array_reduce($arr, "merge");
echo PHP_EOL;
echo array_reduce($arr, "merge", "str0");
@kuredev
Copy link
Author

kuredev commented Nov 18, 2017

実行結果

str1str2str3str4
str0str1str2str3str4

Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment