aboutsummaryrefslogtreecommitdiffstats
path: root/include/text.php
diff options
context:
space:
mode:
authormrjive <mrjive@mrjive.it>2018-02-02 09:23:55 +0100
committerGitHub <noreply@github.com>2018-02-02 09:23:55 +0100
commitd7ecaa8b23a36ea1e9a0f185017930b5552c00b5 (patch)
treebc3c6b600f7949ea3adf6854c0bf1690ae6e772e /include/text.php
parent7ac4b477020689572a50dbc777c968263e86f6c4 (diff)
parent512f3a764361dde44e36fb72c105265d6df298ad (diff)
downloadvolse-hubzilla-d7ecaa8b23a36ea1e9a0f185017930b5552c00b5.tar.gz
volse-hubzilla-d7ecaa8b23a36ea1e9a0f185017930b5552c00b5.tar.bz2
volse-hubzilla-d7ecaa8b23a36ea1e9a0f185017930b5552c00b5.zip
Merge pull request #14 from redmatrix/dev
Dev
Diffstat (limited to 'include/text.php')
-rw-r--r--include/text.php28
1 files changed, 28 insertions, 0 deletions
diff --git a/include/text.php b/include/text.php
index 8ec6ebace..10bbc751a 100644
--- a/include/text.php
+++ b/include/text.php
@@ -3261,3 +3261,31 @@ function purify_filename($s) {
return '';
return $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);
+}
+