php - Number the iframes and display it -
i have piece of code reads space separated urls input string , replaces them iframe
video. want insert number of iframe
above each of them.
below code:
$result = $conn - > query($sql); if ($result - > num_rows > 0) { // output data of each row while ($row = $result - > fetch_assoc()) { $nr = $row['nr']; $playery = $row['player']; $nrplayer = $nrplayer++; //old int (not used) //////remove string iframes , replace tons spaces 1 before every url (that makes string more clear)////// while (strpos($playery, ' ') !== false) { $playery = str_replace(" ", "", $playery); } $playery = str_replace("http", " http", $playery); $playery = str_replace('<iframewidth="420"height="315"src="', ' ', $playery); $playery = str_replace('<iframesrc="', ' ', $playery); ////////remove space of front , in //////// while (mb_substr($playery, 0, 1) == " ") { $playery = substr($playery, 1); } while (mb_substr($playery, 0, -1) == " ") { echo "ok"; $playery = substr($playery, 1); } //////add ads on page//////// require("ads.php"); //////create iframes/////// $nrr = 1; echo $nrr."<br><br><br> <iframe allowfullscreen='1' width='800' height='500' src='".str_replace(' ', "'></iframe> ".$nrr++." <br><br><br> <iframe allowfullscreen='1' width='800' height='500' src='", $playery)."'>"; } }
i have got 1 row , value of string $playery
is
$playery = "http://www.dailymotion.com/swf/x2t2mgd http://www.dailymotion.com/swf/x2t2ury https://drive.google.com/file/d/0b4dzuaecnhcsdlhnlurau0dbqtg/preview https://drive.google.com/file/d/0b6orwphisxtcuvpmd0rntfu3wk0/preview https://drive.google.com/file/d/0b9x5eo1ro_r9uvzzsvjucgtjbgs/preview http://mp4upload.com/embed-t9ve1iot81so.html"
with code, output this:
1 <video> 1 <video> 1 <video> 1 <video>
however, want this:
1 <video> 2 <video> 3 <video> 4 <video>
in php $var++/$var-- expressions executed after statement encapsulated in, $nrr not become incremented until after echo
$var = 1; echo $var++; //1 echo $var; //2
Comments
Post a Comment