0

I load and run a cycle through my XML structure:

$xml = simplexml_load_file(flakk);
foreach ($xml->class as $class)
{
    now how to delete $class ???
}

the unset($class) has no effect.

John Smith
  • 6,129
  • 12
  • 68
  • 123
  • Possible duplicate of http://stackoverflow.com/questions/262351/remove-a-child-with-a-specific-attribute-in-simplexml-for-php – Jamie Bicknell Jul 23 '15 at 19:02

1 Answers1

0

You cant remove foreach element, but can for example so

for($i=count($xml->class); $i--; ) unset($xml->class[$i]);

Or

for($i=count($xml->class); $i--; )  
   if ($xml->class[$i] == AnyValue)   
       unset($xml->class[$i]);
splash58
  • 26,043
  • 3
  • 22
  • 34