Skip to content

Commit

Permalink
Add description.
Browse files Browse the repository at this point in the history
  • Loading branch information
AndyDune committed May 16, 2018
1 parent fa63a1c commit 2856b92
Showing 1 changed file with 21 additions and 1 deletion.
22 changes: 21 additions & 1 deletion README.md
Original file line number Diff line number Diff line change
Expand Up @@ -158,6 +158,26 @@ $instance = new PowerReplace();
$instance->it = 'eat';
$instance->and_it_2 = 'sleep';
$instance->replace($string); // equals to I know words: «eat» and «sleep»
```

## Custom Functions

```
Yup can add own function with replace rules. Markers and function are nor case sensitive.

```php

$string = 'Where is #word:leftAndRight(_)#?';
// or the same
$string = 'Where is #WORD:LEFTANDRIGHT(_)#?';

$functionHolder = new FunctionsHolder();

// add custom function with name leftAndRight
$functionHolder->addFunction('leftAndRight', function ($string, $symbol = '') {
return $symbol . $string . $symbol;
});
$instance = new PowerReplace($functionHolder);
$instance->word = 'center';
$instance->replace($string); // Where is _center_?

```

0 comments on commit 2856b92

Please sign in to comment.