Split a string array into pieces



PHP Snippet 1:

$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;

PHP Snippet 2:

$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;

PHP Snippet 3:

Array(
   [0] => width: 650px;
   [1] => border: 1px solid #000;
)

PHP Snippet 4:

Array(
   [0] => width: 650px;
   [1] => border: 1px solid #000;
   [2] => ;
)

PHP Snippet 5:

explode(';', $array);

PHP Snippet 6:

foreach($array as $item) {
   $mynewarray = explode(";",$item);
   foreach($mynewarray as $newitem) {
        $finalarray[] = $newitem.";";
   }
   //array is ready
}

PHP Snippet 7:

$arr = array('width: 650px;border: 1px solid #000;','width: 100%;background: white;','width: 100%;background: black;');

$arr = explode(';',implode(';',$arr));
for($i=0; $i < sizeof($arr)-1; $i++) { $arr[$i] .= ';'; }

print_r($arr);

PHP Snippet 8:

$a = "";

        foreach($array as $value) {
                flush();
                $a .= explode(";",$value);
        }