- preg_match_all: documentation ( source)
<?php
$long = '/connect=;;41.26.162.36;;192.168.0.100;;8081;;
/connect=;;98.250.16.76;;192.168.0.24;;8080;;
/connect=;;216.152.60.12;;192.168.1.103;;8090;;
/connect=;;91.11.65.110;;192.168.1.3;;8081;;';
if (preg_match_all('/connect=;;([\d\.]+);;([\d\.]+);;(\d+);;/',
$long, $matches, PREG_SET_ORDER)) {
foreach($matches as $match) {
list(,$ip1, $ip2, $port) = $match;
/* Do stuff */
echo "{$ip1} => {$ip2}:{$port}\n";
}
}