1

Im using this script to change title and desc and tags and what it does it changes only title.

       <?
function change_meta_tags($title,$description,$keywords){
        // This function made by Jamil Hammash
    $output = ob_get_contents();
    if ( ob_get_length() > 0) { ob_end_clean(); }
    $patterns = array("/<title>(.*?)<\/title>/","<meta name='description' content='(.*)'>","<meta name='keywords' content='(.*)'>");
    $replacements = array("<title>$title</title>","meta name='description' content='$description'","meta name='keywords' content='$keywords'");

    $output = preg_replace($patterns, $replacements,$output);  
    echo $output;
}
?>

you can see in this site how does it look https://tibiaservers.net/blog/post/how-to-make-ots-website

there are outputted:

echo $_LANG['config']['title'];
     echo $_LANG['config']['desc'];
     echo $_LANG['config']['postTags'];

I used

change_meta_tags($_LANG['config']['title'], $_LANG['config']['desc'],$_LANG['config']['postTags']);

In page source you can see title has changed but no description and keywords

Joseph
  • 5,644
  • 3
  • 18
  • 44
  • 2
    You should use a [DOM parser](https://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php) to parse HTML. Is there any reason you're stripping the `<` and `>` characters from the `meta` elements? – Jeto Jan 20 '20 at 00:26

0 Answers0