The data in the $source string contains white space in strange places like after the [location] instead of just [location] there is [location] . This is also the case at the end of the block where there is not just two new line characters.
I have therefore consrtucted a regular expression which allows for these irregularities. Becuase I am assuming the data comes in this form:
/([location].\n(?s).+?)\n\s\n/
When this is applied to the preg_match_all function it returns the following array:
<?php
$source="........"; // string from earlier
preg_match_all("/(\[location\].*\n(?s).+?)\n\s+\n/", $source, $data);
// all the matches are put in array form in the $data variable
print_r ($data);
?>
This is the scripts output:
Array
(
[0] => Array
(
[0] => [location]
hlocation=L7001
description=7001 Station 2
bitmap=
address=7001
altAddress=
maxLogin=1
capacity=1
eligibilityLoad=0
enabled=True
[1] => [location]
location=L7002
description=7002 Station
bitmap=
address=7002
altAddress=
maxLogin=1
capacity=1
eligibilityLoad=0
enabled=True
[2] => [location]
location=L7003
description=7003 Station
bitmap=
address=7003
altAddress=
maxLogin=1
capacity=1
eligibilityLoad=0
enabled=True
)
[1] => Array
(
[0] => [location]
location=L7001
description=7001 Station 2
bitmap=
address=7001
altAddress=
maxLogin=1
capacity=1
eligibilityLoad=0
enabled=True
[1] => [location]
location=L7002
description=7002 Station
bitmap=
address=7002
altAddress=
maxLogin=1
capacity=1
eligibilityLoad=0
enabled=True
[2] => [location]
location=L7003
description=7003 Station
bitmap=
address=7003
altAddress=
maxLogin=1
capacity=1
eligibilityLoad=0
enabled=True
)
)
Hope this is of some help.