Hey that sort of looks like JSON!
<?php
$file="
string PackageToRun[][] = { {"M16.1","M16.1EP1","M16.2","M17"},
{"Tv16.2","Tv17","Ta17","Ta16.2 MOpenTAS","Tv17.1","Ta17.1","T16.2","T16.2c"} };
";
if( preg_match('#string PackageToRun\[\]\[\] = ({.*});#is', $file, $matches)) {
$data = json_decode(str_replace(array('{','}'), array('[',']'), $matches[1]));
print_r($data);
}
Output:
Array (
[0] => Array (
[0] => M16.1 [1] => M16.1EP1 [2] => M16.2 [3] => M17
)
[1] => Array (
[0] => Tv16.2 [1] => Tv17 [2] => Ta17 [3] => Ta16.2 MOpenTAS
[4] => Tv17.1 [5] => Ta17.1 [6] => T16.2 [7] => T16.2c
)
)
solved How to write regex in php for changing content?