mnybud Posted December 17, 2007 Share Posted December 17, 2007 Is it possible with PHP to take a text file of urls, 1 per line, and extract only the ones with .com extension? If so can anyone help point me in the right direction? Quote Link to comment Share on other sites More sharing options...
paul2463 Posted December 17, 2007 Share Posted December 17, 2007 have a look at <a href="http://uk2.php.net/preg_match"> preg_match() </a> Quote Link to comment Share on other sites More sharing options...
trq Posted December 17, 2007 Share Posted December 17, 2007 <?php $lines = file('urls.txt'); foreach($lines as $line) { if (preg_match('/.com$/',$line)) { echo $line; } } ?> Quote Link to comment Share on other sites More sharing options...
mnybud Posted December 17, 2007 Author Share Posted December 17, 2007 thanks! Quote Link to comment 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.