I have a php code that looks into an xml array; what I want to do is change the next value of that find. I can echo the output correctly, but when trying to change the value I get an fatal error.
I call my function this way:
$xml = replaceDeleteOrAddMethod("void", "method", "put", $templateID_category, $xml, "category", "itsastring");
and the function I made looks like this:
function replaceDeleteOrAddMethod($element, $methodName, $methodValue, $newValue, $xml, $methodstringname, $methodvartype)
{
//echo "replacing Value for: " . $propertyValue;
foreach ($xml->xpath("//" . $element) as $tmp)
{
//echo $tmp->string . "<br>";
if((string) $tmp[$methodName] == $methodValue )
{
if ($tmp->string == $methodstringname)
{
switch ($methodvartype){
case "itsastring":
echo $tmp->string . "<br>";
echo next($tmp->string) . "-> NewValue: " . $newValue . "<br>";
next($tmp->string) = $newValue;
break;
case "itsaint":
echo $tmp->int . "<br>";
next($tmp->int) = $newValue;
break;
case "itsabool":
echo $tmp->bool . "<br>";
next($tmp->bool) = $newValue;
break;
}
}
}
}
return($xml);
}
If I do $tmp->string = $newValue I am able to edit the string with the new value; but next($tmp->string) = $newValue; gives me a fatal error.
Thanks for the help.