I have this string: CO2 + H2O + XO
And I am going for this: CO2 + H2O + NaO.
I have researched this quite a bit and I am at a loss on what to do with a mixture of strings and arrays.
$reactant = 'CO2 + H2O + XO';
$products = str_split($reactant);
foreach ($products as $splitresult)
{
$splitresult = str_replace('X', 'Na', $splitresult);
}
echo $splitresult;
$someElement. This is handled very easily withstr_replace($searchFor, $replaceWith, $subject)str_splitworks better thanexplodefor you?