here is a very simplistic idea... don't know if there can be something really more efficient..
// this is your source text
$sourceStr = "....";
// make a list with the sequences you want to leave untouched
$untouched = array('\"', '" "');
// for each element in your untouched list find a replacement that doen't exist in your text
$untouched_replacements = array();
for ($untouched_index=0; ; $untouched_index++) {
$replacement = "";
for($i=0;;$i++) if (strpos($sourceStr, "R$i")===false) {
$replacement = "R$i";
$untouched_replacements[] = $replacement;
break;
}
// replace the untouched sequences with the safe ones
$sourceStr = str_replace($untouched[$untouched_index], $replacement, $sourceStr);
}
// now split your string
$result = explode(" ", $sourceStr);
// replace back your untouched sequences
for($row; $row<count($result); $row++)
for($i; $i<count($untouched); $i++)
$result[$row] = str_replace($untouched_replacements[$i], $untouched[$i], $result[$row]);
sorry if I missed something... its 2AM here 🙂
try this and tell me if it is any faster .. just out of curiosity 🙂