diff options
author | zotlabs <mike@macgirvin.com> | 2018-02-04 17:01:59 -0800 |
---|---|---|
committer | zotlabs <mike@macgirvin.com> | 2018-02-04 17:01:59 -0800 |
commit | f15fd93f905520fa7f58e7365c838edd382b227c (patch) | |
tree | 92d9c83603c15dc3f978252e3ad9ec7b3d3f41f0 /include | |
parent | 6ad14f4ca009bfa14aa0629d6a53212eb0d14e7f (diff) | |
download | volse-hubzilla-f15fd93f905520fa7f58e7365c838edd382b227c.tar.gz volse-hubzilla-f15fd93f905520fa7f58e7365c838edd382b227c.tar.bz2 volse-hubzilla-f15fd93f905520fa7f58e7365c838edd382b227c.zip |
implode can take its arguments in either order, but let's try to be consistent
Diffstat (limited to 'include')
-rw-r--r-- | include/text.php | 55 |
1 files changed, 29 insertions, 26 deletions
diff --git a/include/text.php b/include/text.php index 10bbc751a..35a367d43 100644 --- a/include/text.php +++ b/include/text.php @@ -2160,6 +2160,35 @@ function ids_to_querystr($arr,$idx = 'id',$quote = false) { } /** + * @brief array_elm_to_str($arr,$elm,$delim = ',') extract unique individual elements from an array of arrays and return them as a string separated by a delimiter + * similar to ids_to_querystr, but allows a different delimiter instead of a db-quote option + * empty elements (evaluated after trim()) are ignored. + * @param $arr array + * @param $elm array key to extract from sub-array + * @param $delim string default ',' + * @returns string + */ + +function array_elm_to_str($arr,$elm,$delim = ',') { + + $tmp = []; + if($arr && is_array($arr)) { + foreach($arr as $x) { + if(is_array($x) && array_key_exists($elm,$x)) { + $z = trim($x[$elm]); + if(($z) && (! in_array($z,$tmp))) { + $tmp[] = $z; + } + } + } + } + return implode($delim,$tmp); +} + + + + +/** * @brief Fetches xchan and hubloc data for an array of items with only an * author_xchan and owner_xchan. * @@ -3263,29 +3292,3 @@ function purify_filename($s) { } -/** - * @brief array_elm_to_str($arr,$elm,$delim = ',') extract unique individual elements from an array of arrays and return them as a string separated by a delimiter - * - * empty elements (evaluated after trim()) are ignored. - * @param $arr array - * @param $elm array key to extract from sub-array - * @param $delim string default ',' - * @returns string - */ - -function array_elm_to_str($arr,$elm,$delim = ',') { - - $tmp = []; - if($arr && is_array($arr)) { - foreach($arr as $x) { - if(is_array($x) && array_key_exists($elm,$x)) { - $z = trim($x[$elm]); - if(($z) && (! in_array($z,$tmp))) { - $tmp[] = $z; - } - } - } - } - return implode($tmp,$delim); -} - |