19declare(strict_types=1);
27 $processing_text = $a_raw_mount_instructions;
29 $found_instructions = [];
33 $open_with_no_close_tag_found =
false;
35 $open_tag_start_pos = strpos($processing_text,
'[');
36 $open_tag_end_pos = strpos($processing_text,
']');
38 if ($open_tag_start_pos !==
false && $open_tag_end_pos !==
false && $open_tag_start_pos < $open_tag_end_pos) {
41 $open_tag_start_pos + 1,
42 $open_tag_end_pos - $open_tag_start_pos - 1
44 $close_tag =
"[/$tag_name]";
46 $close_tag_pos = strpos($processing_text, $close_tag);
48 if ($close_tag_pos !==
false && $open_tag_end_pos < $close_tag_pos) {
49 $found_instructions[$tag_name] = substr(
51 $open_tag_end_pos + 1,
52 $close_tag_pos - $open_tag_end_pos - 1
55 $processing_text = substr($processing_text, $close_tag_pos + strlen($close_tag));
58 $processing_text = substr($processing_text, $open_tag_end_pos + 1);
59 $open_with_no_close_tag_found =
true;
62 }
while ($pair_found || $open_with_no_close_tag_found);
64 if ($found_instructions === []) {
65 return [$a_raw_mount_instructions];
68 return $found_instructions;
parseInstructionsToAssocArray(string $a_raw_mount_instructions)