I have the following PHP Function that I want to simplify, What is the best and most efficient way?
function XMLToObject($dirtyXML) {
$clean_xml = str_ireplace([
'SOAP-ENV:',
'SOAP:'
], '', $dirtyXML);
$clean_xml2 = str_ireplace([
'common:',
''
], '', $clean_xml);
$clean_xml3 = str_ireplace([
'pdt:',
''
], '', $clean_xml2);
$clean_xml4 = str_ireplace([
'apd:',
''
], '', $clean_xml3);
$clean_xml5 = str_ireplace([
'bs7666:',
''
], '', $clean_xml4);
$xml = simplexml_load_string($clean_xml5);
return $xml;
}
I was thinking of using another function like...
function replace($oldVal,$newVal)
Then iterate over this 4 times with my different value pairs?