forked from confirm/PhpZabbixApi
-
Notifications
You must be signed in to change notification settings - Fork 0
/
Copy pathreplacePlaceholders.func.php
46 lines (41 loc) · 1.42 KB
/
replacePlaceholders.func.php
1
2
3
4
5
6
7
8
9
10
11
12
13
14
15
16
17
18
19
20
21
22
23
24
25
26
27
28
29
30
31
32
33
34
35
36
37
38
39
40
41
42
43
44
45
46
<?php
/**
* @file replacePlaceholders.func.php
*
* @brief Implementation of the replacePlaceholders() function.
*
* This file is part of PhpZabbixApi.
*
* PhpZabbixApi is free software: you can redistribute it and/or modify
* it under the terms of the GNU General Public License as published by
* the Free Software Foundation, either version 3 of the License, or
* (at your option) any later version.
*
* PhpZabbixApi 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 General Public License for more details.
*
* You should have received a copy of the GNU General Public License
* along with PhpZabbixApi. If not, see <http://www.gnu.org/licenses/>.
*
* @copyright GNU General Public License
* @author confirm IT solutions GmbH, Rathausstrase 14, CH-6340 Baar
*/
/**
* @brief Replace placeholders in a string.
*
* Placeholders in the string are surrounded by '<' and '>' (e.g. '<FOOBAR>').
*
* @param $string Any string.
* @param $placeholders Array with placeholders (key-value pair).
*
* @retval string Replaced string.
*/
function replacePlaceholders($string, $placeholders)
{
foreach($placeholders as $placeholder => $value)
$string = str_replace('<'.strtoupper($placeholder).'>', $value, $string);
return $string;
}
?>