I have a text file with this format and I want to convert this into an array following the format.
Text File Content:
Header = "This is header"
Object class = "First"
min_size = 0
max_size = 727.555
content= true
size = 1
item []:
item [1]:
class = "Convert"
name = "CONTENT"
min_size = 0
max_size = 727.555
intervals: size = 474
intervals [1]:
min_size = 0
max_size = 13.139997023062838
type = ""
intervals [2]:
min_size = 13.139997023062838
max_size = 14.763036269953904
type = "this is a type"
intervals [3]:
min_size = 14.763036269953904
max_size = 17.01
type = ""
intervals [4]:
min_size = 17.01
max_size = 18.193
type = ""
I want to convert this to an array something like this if possible:
Array
(
[1] =>
Array(
['min_size'] = 0,
['max_size'] = 13.139997023062838,
['type'] = ""
)
[2] =>
Array(
['min_size'] = 13.139997023062838,
['max_size'] = 14.763036269953904,
['type'] = "this is a type"
)
I already tried something like this:
$file = "array.txt";// Your Temp Uploaded file
$cols = array();
ini_set('auto_detect_line_endings', true);
$fh = fopen($file, 'r');
$i = 0;
while (($line = fgetcsv($fh, 1000, "\t")) !== false) {
$cols[] = $line;
}
echo "<pre>";
print_r($cols);
echo "</pre>";
But this only turned everything into a single array.
Is this possible?