PHP code example of jkque / laravel-string-replace
1. Go to this page and download the library: Download jkque/laravel-string-replace library. Choose the download type require.
2. Extract the ZIP file and open the index.php.
3. Add this code to the index.php.
<?php
require_once('vendor/autoload.php');
/* Start to develop here. Best regards https://php-download.com/ */
jkque / laravel-string-replace example snippets
use Jkque\StringReplace\StringReplace;
use App\User;
class UserStringReplace extends StringReplace
{
public function __construct(User $user)
{
$this->variables([
'@name' => $user->name,
]);
}
}
use Jkque\StringReplace\StringReplace;
$string = 'We are awesome <p>in php</p> replacethis';
$string = StringReplace::content($string)
->variables([
'replacethis' => 'coding',
])
->replace(); // the ending method to be called
$string->when($somecondtion, function ($string) {
// do something;
})
use Jkque\StringReplace\StringReplace;
class RemoveBadWords extends StringReplace
{
public function __construct()
{
$this->variables([
'badword' => '*',
]);
}
}