-1

THIS IS MY CODE

when the page refresh , i want to change meta content according to that. Make a Code according to that , & post in comment

<html>
<head>
<meta property="fb:app_id" content="366632706686339" />
<meta name="twitter:card" value="summary"> 
<meta property="og:title" content="?></title>" />
<meta http-equiv="refresh" content="0">
<title><?php

$titles = array();

$titles[] = "Possible Title 1";
$titles[] = "Possible Title 2";
$titles[] = "Etc. Etc.";

 srand ((float) microtime() * 10000000); // Seed the random number generator

echo $titles[array_rand($titles)]; // Pick a random item from the array and output it
?></title>
</head>
<body>
</body>
</html>

3 Answers3

0

Check this and tell me if works.

<html>
<head>
<meta property="fb:app_id" content="366632706686339" />
<meta name="twitter:card" value="summary">     
<title><?php

$titles = array();

$titles[] = "Possible Title 1";
$titles[] = "Possible Title 2";
$titles[] = "Etc. Etc.";

 srand ((float) microtime() * 10000000); // Seed the random number generator

echo $titles[array_rand($titles)]; // Pick a random item from the array and output it
?></title>
<meta property="og:title" content="<?= $titles[array_rand($titles)] ?>" />
</head>
<body>
</body>
</html>
Roy Bogado
  • 4,299
  • 1
  • 15
  • 31
0

Use This:

<meta property="og:title" content="<?=$titles[0]?>" />
foobar
  • 571
  • 1
  • 5
  • 20
0

Use this code (i've edited your code for you)

<?php

        $titles = array();

        $titles[] = "Possible Title 1";
        $titles[] = "Possible Title 2";
        $titles[] = "Etc. Etc.";

         srand ((float) microtime() * 10000000); // Seed the random number generator

        $titles[array_rand($titles)]; // Pick a random item from the array and output it
        ?>



        <html>
        <head>
        <meta property="fb:app_id" content="366632706686339" />
        <meta name="twitter:card" value="summary"> 
        <meta property="og:title" content="<?=$titles[array_rand($titles)];?>" />
        <meta http-equiv="refresh" content="0">
        <title><?=$titles[array_rand($titles)];?></title>
        </head>
        <body>
        </body>
        </html>
foobar
  • 571
  • 1
  • 5
  • 20