<?php
$text = <<<EOD
PRD Hervey Bay 07 2525 1919
RG Sprake & Co Maryborough 4141 2424
Owner Robert - 0429 966 391
Owner Maureen - 07 8888 4444 - 0422000 111
Owner Wayne - 0430 555 666
Builder Scott - 0444 555 777
EOD;
preg_match_all('/^(Owner |Builder )?(.*?)(?=-| \d)[- ]+(.*)$/m', $text, $matches);
array_walk($matches[3], function (&$v) { $v = preg_replace('/[^\d]/', '', $v); });
print_r($matches);
- Output for 7.1.25 - 7.1.33, 7.2.0 - 7.2.33, 7.3.0 - 7.3.33, 7.4.0 - 7.4.33, 8.0.0 - 8.0.30, 8.1.0 - 8.1.28, 8.2.0 - 8.2.18, 8.3.0 - 8.3.4, 8.3.6
- Array
(
[0] => Array
(
[0] => PRD Hervey Bay 07 2525 1919
[1] => RG Sprake & Co Maryborough 4141 2424
[2] => Owner Robert - 0429 966 391
[3] => Owner Maureen - 07 8888 4444 - 0422000 111
[4] => Owner Wayne - 0430 555 666
[5] => Builder Scott - 0444 555 777
)
[1] => Array
(
[0] =>
[1] =>
[2] => Owner
[3] => Owner
[4] => Owner
[5] => Builder
)
[2] => Array
(
[0] => PRD Hervey Bay
[1] => RG Sprake & Co Maryborough
[2] => Robert
[3] => Maureen
[4] => Wayne
[5] => Scott
)
[3] => Array
(
[0] => 0725251919
[1] => 41412424
[2] => 0429966391
[3] => 07888844440422000111
[4] => 0430555666
[5] => 0444555777
)
)
- Output for 8.3.5
- Warning: PHP Startup: Unable to load dynamic library 'sodium.so' (tried: /usr/lib/php/8.3.5/modules/sodium.so (libsodium.so.23: cannot open shared object file: No such file or directory), /usr/lib/php/8.3.5/modules/sodium.so.so (/usr/lib/php/8.3.5/modules/sodium.so.so: cannot open shared object file: No such file or directory)) in Unknown on line 0
Array
(
[0] => Array
(
[0] => PRD Hervey Bay 07 2525 1919
[1] => RG Sprake & Co Maryborough 4141 2424
[2] => Owner Robert - 0429 966 391
[3] => Owner Maureen - 07 8888 4444 - 0422000 111
[4] => Owner Wayne - 0430 555 666
[5] => Builder Scott - 0444 555 777
)
[1] => Array
(
[0] =>
[1] =>
[2] => Owner
[3] => Owner
[4] => Owner
[5] => Builder
)
[2] => Array
(
[0] => PRD Hervey Bay
[1] => RG Sprake & Co Maryborough
[2] => Robert
[3] => Maureen
[4] => Wayne
[5] => Scott
)
[3] => Array
(
[0] => 0725251919
[1] => 41412424
[2] => 0429966391
[3] => 07888844440422000111
[4] => 0430555666
[5] => 0444555777
)
)
preferences:
166.57 ms | 404 KiB | 181 Q