Thread Rating:
  • 0 Vote(s) - 0 Average
  • 1
  • 2
  • 3
  • 4
  • 5
QUESTION Foreach how?
#3
(2016-11-24, 01:01:02)shawn_a Wrote: does your input data change also
"$atts= $data->children();" instead of attributes , is that correct for the input data ?

It looks ok at a glance, hmm

also you are modifying your foreach value variable $data
$data = $xml->addChild('data');
use another varname like $node




PHP Code:
foreach ($testfile->data as $data
 
   {
 
                   
        $atts
$data->children();
 
       $node$xml->addChild('data');
 
       $node->addChild('name'$atts['name']);
 
                                   
    


Thank shawn_a for your reply.

After your suggestion looks like this:

Code:
<?xml version="1.0" encoding="UTF-8"?>
<test><data><name/></data><data><name>6</name></data></test>

previous entries are empty only displays the last!?
Reply


Messages In This Thread
Foreach how? - by smdp-1971 - 2016-11-24, 00:50:10
RE: Foreach how? - by shawn_a - 2016-11-24, 01:01:02
RE: Foreach how? - by smdp-1971 - 2016-11-24, 02:16:07
RE: Foreach how? - by smdp-1971 - 2016-12-01, 00:36:20



Users browsing this thread: 1 Guest(s)