Collections functions
General functions
Node functions
Render functions
Theme permission functions
User functions
Resource functions



Returns a string with all occurrences of the $mixedplaceholder in $subject replaced with the $mixedreplace.
If $mixedplaceholder is a string but $mixedreplace is an array, the $mixedreplace is imploded to a string using $separator.
The replace values are formatted according to the formatting of the placeholders.
The placeholders may be written in UPPERCASE, lowercase or Uppercasefirst.
Each placeholder will be replaced by the replace value,
written with the same case as the placeholder.
It's possible to also include "?" as a placeholder for legacy reasons.

Example #1:
str_replace_formatted_placeholder("%extension", $resource["file_extension"], $lang["originalfileoftype"], true)
will search for the three words "%EXTENSION", "%extension" and "%Extension" and also the char "?"
in the string $lang["originalfileoftype"]. If the found placeholder is %extension
it will be replaced by the value of $resource["file_extension"],
written in lowercase. If the found placeholder instead would have been "?" the value
would have been written in UPPERCASE.

Example #2:
str_replace_formatted_placeholder("%resourcetypes%", $searched_resource_types_names_array,
$lang["resourcetypes-collections"], false, $lang["resourcetypes_separator"])
will search for the three words "%RESOURCETYPES%", "%resourcetypes%" and "%Resourcetypes%"
in the string $lang["resourcetypes-collections"]. If the found placeholder is %resourcetypes%
all elements in $searched_resource_types_names_array will be written in lowercase and separated by
$lang["resourcetypes_separator"] before the resulting string will replace the placeholder.


$mixedplaceholder mixed
$mixedreplace mixed
$subject mixed
$question_mark mixed false
$separator string "




include/language_functions.php lines 254 to 300


function str_replace_formatted_placeholder($mixedplaceholder$mixedreplace$subject$question_mark false$separator ", ")
# Creates a multi-dimensional array of the placeholders written in different case styles.
$array_placeholder = array();
    if (
is_array($mixedplaceholder)) {$placeholder $mixedplaceholder;}
    else {
$placeholder = array($mixedplaceholder);}
    for (
$n 0;$n<count($placeholder);$n++)
$array_placeholder[$n] = array(strtoupper($placeholder[$n]), strtolower($placeholder[$n]), ucfirstletter($placeholder[$n]));

# Creates a multi-dimensional array of the replace values written in different case styles.
if (is_array($mixedreplace)) {$replace $mixedreplace;}
    else {
$replace = array($mixedreplace);}
    for (
$n 0;$n<count($replace);$n++)
$array_replace[$n] = array(strtoupper($replace[$n]), strtolower($replace[$n]), ucfirst(strtolower($replace[$n])));

# Adds "?" to the arrays if required.
if ($question_mark)
$array_placeholder[] = "?";
$array_replace[] = strtoupper($replace[0]);

# Replaces the placeholders with the replace values and returns the new string.
$result $subject;
    if (
count($placeholder)==&& count($replace)>1)
# The placeholder shall be replaced by an imploded array.
$array_replace_strings = array(implode($separatorarray_map(function($column) {return $column[0];}, $array_replace)), implode($separatorarray_map(function($column) {return $column[1];}, $array_replace)), implode($separatorarray_map(function($column) {return $column[2];}, $array_replace)));
$result str_replace($array_placeholder[0], $array_replace_strings$result);
        for (
            if (!isset(
$array_replace[$n][0])) {break;}
$result str_replace($array_placeholder[$n], $array_replace[$n], $result);

This article was last updated 23rd July 2024 07:05 Europe/London time based on the source file dated 3rd May 2024 14:45 Europe/London time.