Created
July 5, 2021 20:26
-
-
Save mrabro/67f56ec2da1fd1ee2f42757236f2c772 to your computer and use it in GitHub Desktop.
Php Function to replace the keywords from text
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
<?php | |
public function replace_shortcode( $args, $body ) { | |
$tags = array( | |
'email' => "", | |
'firstname' => "", | |
'lastname' => "", | |
); | |
$tags = array_merge( $tags, $args ); | |
extract( $tags ); | |
$tags = array( '{email}', | |
'{firstname}', | |
'{lastname}', | |
); | |
$values = array( $email, | |
$firstname , | |
$lastname, | |
); | |
$message = str_replace($tags, $values, $body); | |
$message = nl2br($message); | |
$message = htmlspecialchars_decode($message,ENT_QUOTES); | |
return $message; | |
} |
Sign up for free
to join this conversation on GitHub.
Already have an account?
Sign in to comment