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? Link to comment https://forums.phpfreaks.com/topic/82085-solved-is-this-possible/ 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> Link to comment https://forums.phpfreaks.com/topic/82085-solved-is-this-possible/#findComment-417104 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; } } ?> Link to comment https://forums.phpfreaks.com/topic/82085-solved-is-this-possible/#findComment-417129 Share on other sites More sharing options...
mnybud Posted December 17, 2007 Author Share Posted December 17, 2007 thanks! Link to comment https://forums.phpfreaks.com/topic/82085-solved-is-this-possible/#findComment-417132 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.