fork(1) download
  1. <?php
  2. $str='(DESCRIPTION=(ADDRESS_LIST=(ADDRESS=(PROTOCOL=TCP)(HOST=FQDN1)(PORT=1234))(ADDRESS=(PROTOCOL=TCP)(HOST=FQDN2)(PORT=5678))(ADDRESS=(PROTOCOL=TCP)(HOST=FQDN3)(PORT=9012))(ADDRESS=(PROTOCOL=TCP)(HOST=FQDN4)(PORT=3456)))(CONNECT_DATA=(SERVICE_NAME=STUFF)))';
  3. if (preg_match_all('~HOST=([^)\s]+).*?PORT=([^)\s]+)~', $str, $arr))
  4. print_r($arr);
  5. ?>
Success #stdin #stdout 0.01s 20568KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => HOST=FQDN1)(PORT=1234
            [1] => HOST=FQDN2)(PORT=5678
            [2] => HOST=FQDN3)(PORT=9012
            [3] => HOST=FQDN4)(PORT=3456
        )

    [1] => Array
        (
            [0] => FQDN1
            [1] => FQDN2
            [2] => FQDN3
            [3] => FQDN4
        )

    [2] => Array
        (
            [0] => 1234
            [1] => 5678
            [2] => 9012
            [3] => 3456
        )

)