drisate Posted February 27, 2012 Share Posted February 27, 2012 hey guys i need to extract all the IP's of a string and loop them for more operations but for some reason i only get the first one <?php $string = '80.37.14.13 80.37.14.14 80.37.14.15'; preg_match("/\d{1,3}\.\d{1,3}\.\d{1,3}\.\d{1,3}/", $string, $matches); foreach ($matches as $ip){ echo "$ip<br>"; } ?> The string is not really seperated by spaces ... it can actualy be messy and have ips rapped arround a lot of code. The regex works because i do get the first one ... What did i miss? Link to comment https://forums.phpfreaks.com/topic/257887-extracting-all-ips-of-a-string/ Share on other sites More sharing options...
drisate Posted February 27, 2012 Author Share Posted February 27, 2012 lol sorry forgot i had to use preg_match_all hehe Link to comment https://forums.phpfreaks.com/topic/257887-extracting-all-ips-of-a-string/#findComment-1321796 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.