Skip to content

Instantly share code, notes, and snippets.

@mrabro
Created July 5, 2021 20:26
Show Gist options
  • Star 0 You must be signed in to star a gist
  • Fork 0 You must be signed in to fork a gist
  • Save mrabro/67f56ec2da1fd1ee2f42757236f2c772 to your computer and use it in GitHub Desktop.
Save mrabro/67f56ec2da1fd1ee2f42757236f2c772 to your computer and use it in GitHub Desktop.
Php Function to replace the keywords from text
<?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