Search code examples
phphtmlremove-if

How can I remove a spcific html meta tag with php?


I would like to this:
If php found this specific meta tag in the html source,then delete from header:

<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />

I tryed this way, but dosen't work:

if ( $fullmeta == '<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />') {
     $fullmeta="";  
   }

The full codeblock where the full meta is declareted:

<? 
 $video_url = get_field('video_urlasd');
if (isset($video_url) && $video_url !== "https://") {
  $meta1='<meta property="og:video:type" content="application/x-shockwave-flash" />';
  $skinURL="https://neocsatblog.info/skinning-sdk/five/newtube/newtube.xml";
  $meta2=' <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file='.urlencode($video_url).'&autostart=true&skinName=newtube&skinURL='.urlencode($skinURL).'" />';
  $fullmeta=$meta1.$meta2;
  echo $fullmeta;
  }else{
      echo chop($fullmeta,"asd");
  }
   if ( $fullmeta == '<meta property="og:video:type" content="application/x-shockwave-flash" /> <meta property="og:video" content="https://www.neocsatblog.info/jwplayer/player.swf?file=&autostart=true&skinName=newtube&skinURL=https%3A%2F%2Fneocsatblog.info%2Fskinning-sdk%2Ffive%2Fnewtube%2Fnewtube.xml" />') {
     echo $fullmeta="";  
   }
  ?>

I don't know why, because on the HTML source I found it and looks like same as I copied!


Solution

  • Replace this part of your code

    if (isset($video_url) && $video_url !== "https://") {
    

    with this

    if (!empty($video_url) && $video_url !== "https://") {