- var_dump: documentation ( source)
- array_combine: documentation ( source)
- function_exists: documentation ( source)
- preg_match_all: documentation ( source)
<?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);