Download the PHP package andydune/string-replace without Composer
On this page you can find all versions of the php package andydune/string-replace. It is possible to download/install these versions without Composer. Possible dependencies are resolved automatically.
Download andydune/string-replace
More information about andydune/string-replace
Files in andydune/string-replace
Package string-replace
Short Description Replace markers in string with data.
License MIT
Homepage https://github.com/AndyDune/StringReplace
Informations about the package string-replace
StringReplace
It replace in given string meta data with real data.
Requirements
PHP version >= 7.2
Installation
Installation using composer:
Or if composer was not installed globally:
Or edit your composer.json
:
And execute command:
SimpleReplace
It's very simple and lightweight replace methods. It uses str_replace
function.
There is no any logic in it and it will no replace statements if no data to replace.
PowerReplace
It powerful replace class with string analytics with regular. There are many functions built-in lib and you may add custom easily.
No case sensitive
Functions
Functions are described next to marker after :
(you can change separator).
Functions can get parameters: #CODE:maxlen(10)#
or #CODE:maxlen("10")#
Symbols: : ( ) , " ' are reserved to use as parameters for function. So if you want to use it you mast encase it with quotes (or single quotes).
This is correct usage:
More then one function : #CODE:maxlen(10):escape#
escape
Apply htmlspecialchars
with inserted value.
addcomma
It adds comma before inserted value if it is not empty.
comma
function may get params: comma(param1, param2)
- param1 set to
1
if you want to miss first comma appearance in string - param2 set to
1
if you want to begin new group of words for next missing of first comma appearance in string
maxlen
Replace marker with value if string behind this one is less then poined in parameter.
printf
Print formatted string if it is not empty.
plural
Pluralize the title for number.
pluralrus
Russian pluralize the title for number.
prefix
It shows given string as prefix only if value behind the key is not empty.
postfix
It shows given string as postfix only if value behind the key is not empty.
showIfEqual
It shows string given in second param if first param is equal to value behind the placeholder.
showIfOtherValueNotEmpty
It shows string value behind the current placeholder if another is not empty.
Custom Functions
You can add your own functions with replace rules. Markers and functions are not case sensitive.
Application
All versions of string-replace with dependencies
ext-mbstring Version *