I would personally use the preg_split
to get rid of that extra array element that would occur from the final semicolon...
$newarray = array();
foreach ($array as $i => $styles):
// Split the statement by any semicolons, no empty values in the array
$styles = preg_split("/;/", $styles, -1, PREG_SPLIT_NO_EMPTY);
// Add the semicolon back onto each part
foreach ($styles as $j => $style) $styles[$j] .= ";";
// Store those styles in a new array
$newarray[$i] = $styles;
endforeach;
Edit: Don't add the semicolon to each line:
$newarray = array();
foreach ($array as $i => $styles):
// Split the statement by any semicolons, no empty values in the array
$newarray[$i] = preg_split("/;/", $styles, -1, PREG_SPLIT_NO_EMPTY);
endforeach;
Which should output:
Array(
[0] => width: 650px;
[1] => border: 1px solid #000;
)
Unlike explode, which should output:
Array(
[0] => width: 650px;
[1] => border: 1px solid #000;
[2] => ;
)