<?php
// Array containing semi-colon space separated items
$plantPartNames = array(
"a",
"b",
"c; d; e",
"f",
"g",
"h; i; j",
"k"
);
// Store additions
$additions = array();
// Loop through array
foreach ($plantPartNames as &$val) {
// Check for semi-colon space
if (strpos($val, "; ") === false) {
continue;
}
// Found so split.
$split = explode("; ", $val);
// Shift the first item off and set to referenced variable
$val = array_shift($split);
// Add remaining to additions
$additions = array_merge($additions, $split);
}
// Add any additions to array
$plantPartNames = array_merge($plantPartNames, $additions);
// Print
var_export($plantPartNames);
// Produces the following:
// array ( 0 => 'a', 1 => 'b', 2 => 'c', 3 => 'f', 4 => 'g', 5 => 'h', 6 => 'k', 7 => 'd', 8 => 'e', 9 => 'i', 10 => 'j', )
?>