Guest MrLeN Posted June 20, 2012 Share Posted June 20, 2012 <iframe id="fr" src="http://www.youtube.com/subscribe_widget?p=USERNAME" style="overflow: hidden; height: 105px; width: 300px; border: 0;" scrolling="no" frameBorder="0"></iframe> The above code allows me to display a subscribe widget for YouTube. However, I want to put it in a php loop and display USERNAME from a text file. And I will make a text file like this: username1 username2 How can I make a loop and make the loop display all the names in the text file? Can someone please show me the code? I know how to do a loop. It explains here: http://www.w3schools.com/php/php_looping_for.asp But I don't know how to make the loop get the lines out of the text file. Can someone help please? Quote Link to comment https://forums.phpfreaks.com/topic/264495-loop-from-a-text-fle/ Share on other sites More sharing options...
trq Posted June 20, 2012 Share Posted June 20, 2012 <?php $names = file('/path/to/file/names.txt'); foreach ($names as $name) { echo '<iframe id="fr" src="http://www.youtube.com/subscribe_widget?p=' . $name . '" style="overflow: hidden; height: 105px; width: 300px; border: 0;" scrolling="no" frameBorder="0"></iframe>'; } Quote Link to comment https://forums.phpfreaks.com/topic/264495-loop-from-a-text-fle/#findComment-1355447 Share on other sites More sharing options...
Guest MrLeN Posted June 20, 2012 Share Posted June 20, 2012 wow, works great - thanks heaps Quote Link to comment https://forums.phpfreaks.com/topic/264495-loop-from-a-text-fle/#findComment-1355448 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.