3v4l.org

run code in 300+ PHP versions simultaneously
<?php if(!function_exists('array_combine')) { function array_combine($keyarray, $valuearray) { $_ret = array(); foreach($keyarray as $index => $key) $_ret[$key]=$valuearray[$index]; return $_ret; } } $stylestr = 'text-align:center;display:block;'; $_style = array(); preg_match_all('#(.*?):(.*?);#', $stylestr, $matches); //foreach($matches[1] as $index => $key) $_style[$key]=$matches[2][$index]; $_style = array_combine($matches[1], $matches[2]); var_dump($_style);

preferences:
36.84 ms | 402 KiB | 5 Q