Skip to content
New issue

Have a question about this project? Sign up for a free GitHub account to open an issue and contact its maintainers and the community.

By clicking “Sign up for GitHub”, you agree to our terms of service and privacy statement. We’ll occasionally send you account related emails.

Already on GitHub? Sign in to your account

Added rm_string in text_helper #3465

Closed
wants to merge 4 commits into from
Closed
Changes from all commits
Commits
File filter

Filter by extension

Filter by extension

Conversations
Failed to load comments.
Loading
Jump to
Jump to file
Failed to load files.
Loading
Diff view
Diff view
25 changes: 25 additions & 0 deletions system/Helpers/text_helper.php
Original file line number Diff line number Diff line change
Expand Up @@ -880,4 +880,29 @@ function excerpt(string $text, string $phrase = null, int $radius = 100, string
}

//--------------------------------------------------------------------
if (! function_exists('replace_string'))
{
/**
* Remove String.
*
* Allows to removed specific keyword or fields from string
*
* @param string $string Given String
* @param array $values Given value that will be replace
* @param integer $replace Matches any of the patterns are replaced with the replacement string.
*
* @return string
*
*/
function replace_string(string $string, array $values, string $replace = ''): string
{
foreach ($values as $value)
{
$string = preg_replace("~{$value}~s", $replace, $string);
}
return $string;
}

Copy link
Member

@samsonasik samsonasik Aug 9, 2020

Choose a reason for hiding this comment

The reason will be displayed to describe this comment to others. Learn more.

missing close }, also, again, please provide unit tests and follow coding style, do composer update and it will automatically fix it on next commit.


}
//--------------------------------------------------------------------