fork download
  1. <?php
  2. $value = "{2-1}{3-1}{5-0}";
  3. preg_match_all( '/\{(\d+)-(\d+)\}/', $value, $matches);
  4. $result = array_combine( $matches[1], $matches[2]);
  5. print_r( $result);
  6. ?>
Success #stdin #stdout 0.01s 20520KB
stdin
Standard input is empty
stdout
Array
(
    [2] => 1
    [3] => 1
    [5] => 0
)