fork download
  1. <?php
  2.  
  3. $s = "[NAME: abc] [EMAIL: cde] [TIMEFRAME: efg] [BUDGET: hij] [MESSAGE: klm]";
  4. if (preg_match_all('~\[(\w+):\s*([^][]*)]~', $s, $m)) {
  5. print_r(array_combine($m[0], $m[1]));
  6. }
Success #stdin #stdout 0s 82624KB
stdin
Standard input is empty
stdout
Array
(
    [NAME] => abc
    [EMAIL] => cde
    [TIMEFRAME] => efg
    [BUDGET] => hij
    [MESSAGE] => klm
)