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? Quote Link to comment 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 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.