I have a PHP code that draws my subscriber count from my YouTube channel and sets it as an integer variable, $subs
. I need to use the variable $subs
in this piece of HTML code.
HTML Code:
<div class="col-md-6 bottommargin-sm">
<div class="counter counter-small"><span data-from="100" data-to="$subs" data-refresh-interval="50" data-speed="2000" data-comma="true"></span></div>
<h5 class="nobottommargin">Subs</h5>
</div>
PHP Code:
<?php
set_time_limit(0);
function retrieveContent($url){
$file = fopen($url,"rb");
if (!$file) return "";
while (feof ($file)===false) {
$line = fgets ($file, 1024);
$salida .= $line;
}
fclose($file);
return $salida;
}
{
$content = retrieveContent("youtube.com/user/geekawhat/about"); $start = strpos($content,'<span class="about-stat"><b>');
$end = strpos($content,'</b>',$start+1);
$output = substr($content,$start,$end-$start);
$subs = (int)$output;
echo "$output";
}
?>
It is a counter, and I want it to count to whatever that variable equals. I have placed the variable in the data-to field, which informs the counter what to count upto - how do I get this to work? (This does work btw with a number inserted into the data-to field)