fork download
  1. <?php
  2. preg_match_all("/([0-9]+)(?:\[([^\]]*)\])?A/", "123[SomeText]A345[SomeOtherText]A678A", $matches);
  3. print_r($matches);
  4. ?>
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Array
(
    [0] => Array
        (
            [0] => 123[SomeText]A
            [1] => 345[SomeOtherText]A
            [2] => 678A
        )

    [1] => Array
        (
            [0] => 123
            [1] => 345
            [2] => 678
        )

    [2] => Array
        (
            [0] => SomeText
            [1] => SomeOtherText
            [2] => 
        )

)