Archived
1
0
Disbranĉigi 0
Ĉi tiu deponejo arĥiviĝis je 2024-01-28. Vi povas vidi kaj elŝuti dosierojn, sed ne povas puŝi nek raporti problemojn nek tirpeti.
blagoblag/res/lib/array.php

47 lines
1.2 KiB
PHP
Raw Normal View History

2019-02-13 20:43:32 -06:00
<?php
/* This file is free software: you can redistribute it and/or modify
it under the terms of version 3 of the GNU Affero General Public
License as published by the Free Software Foundation.
This file is distributed in the hope that it will be useful,
but WITHOUT ANY WARRANTY; without even the implied warranty of
MERCHANTABILITY or FITNESS FOR A PARTICULAR PURPOSE. See the
GNU Affero General Public License for more details. */
// ARRAY -- > STRING
// Turn a 1D array into a comma-seperated string
2019-02-15 08:32:58 -06:00
function comma_sep($array, $seperator=", ") {
global $string;
$string = $seperator;
2019-02-13 20:43:32 -06:00
global $stack;
$stack = "";
$comma_print = function($item) {
$GLOBALS['stack'] = $GLOBALS['stack']
2019-02-15 08:32:58 -06:00
. $GLOBALS['string'] . $item;
2019-02-13 20:43:32 -06:00
};
array_map($comma_print, $array);
2019-02-15 08:32:58 -06:00
$stack = preg_replace('/^' . $string . '/', '', $stack);
2019-02-13 20:43:32 -06:00
return $stack;
}
2019-02-15 08:32:58 -06:00
// STRING STRING [ARRAY] --> ARRAY
// Return exports for Twig-- with the required global & local exports,
// along with any optional local ones.
2019-02-18 23:24:07 -06:00
function make_exports($depth, $title, $mark, $local = array()) {
2019-02-15 08:32:58 -06:00
$exports = $GLOBALS['twig_exports'];
2019-02-18 23:24:07 -06:00
$exports['mark'] = $mark;
2019-02-15 08:32:58 -06:00
$exports['depth'] = $depth;
$exports['title'] = $title;
return array_merge($exports, $local);
}
2019-02-13 20:43:32 -06:00
?>