I am writing a function to decrypt the contents of a SimpleXML object in place.
function xmlWalkerDecrypt(&$xmlObj, $aesKey) {
if ($xmlObj->count()>0){
foreach($xmlObj as &$child){ //line 154
xmlWalkerDecrypt($child, $aesKey);
}
}
else{
$xmlObj = companyAES($xmlObj, $aesKey, 'decrypt');
}
}
This is throwing a the following error in WAMP:
Fatal error: An iterator cannot be used with foreach by reference in C:\wamp\www\_assets\walk.php on line 154
Is it possible to iterate through a SimpleXML object for the purpose of editing by reference, rather than outputting?
I've also tried:
function xmlWalkerDecrypt(&$xmlObj, $aesKey) {
if ($xmlObj->count()>0){
foreach($xmlObj->children() as &$child){ //line 154
xmlWalkerDecrypt($child, $aesKey);
}
}
else{
$xmlObj = companyAES($xmlObj, $aesKey, 'decrypt');
}
}
but that produces the following error:
Fatal error: Cannot create references to elements of a temporary array expression in C:\wamp\www_assets\myFile.php on line 154`