3v4l.org

run code in 150+ php & hhvm versions
Bugs & Features
<?php $text = <<<EOD [a-1]****************** [b-2]********** [c-3]*** EOD; preg_match_all('/^\[([^\]]*+)](.*?)$/m' , $text, $matches, PREG_SET_ORDER); $result = array(); foreach ($matches as $match) { $result[$match[1]] = $match[2]; } var_dump($result);
Output for 4.3.0 - 7.1.0
array(3) { ["a-1"]=> string(18) "******************" ["b-2"]=> string(10) "**********" ["c-3"]=> string(3) "***" }