0

I'm not a programmer, but I have to do some work with my site.

Please tell me how to do it

Question in the comment code.

<?php
 for ($o = 1; $o < 9 ; $o++) {
$file = '/patch/to/file_'.$o.'.xml';

 $doc = new DOMDocument();
 $doc->load($file);
 $destinations = $doc->getElementsByTagName("model");
 foreach ($destinations as $destination) {
    foreach($destination->childNodes as $child) {
        if ($child->nodeType == XML_CDATA_SECTION_NODE) {

            ${'czy' . $o}[] = $child->textContent;
          }
      }
   }

}


$merge = array_merge($czy1, $czy2, $czy3, $czy4, $czy5, $czy6, $czy7, $czy8);
// How do this?? but in loop function (from $czy1 to $czy8)?






2
  • Hint: array_merge(array_merge($czy1, $czy2), $c3) equals array_merge($czy1, $czy2, $c3). Commented Mar 30, 2019 at 11:22
  • Thanks for your Hint but I still I don't now how do it Commented Mar 30, 2019 at 12:32

1 Answer 1

1
 for ($o = 1; $o < 9 ; $o++) {
$file = '/patch/to/file_'.$o.'.xml';

 $result = [];

 $doc = new DOMDocument();
 $doc->load($file);
 $destinations = $doc->getElementsByTagName("model");
 foreach ($destinations as $destination) {
    foreach($destination->childNodes as $child) {
        if ($child->nodeType == XML_CDATA_SECTION_NODE) {

            $result = array_merge($result, $child->textContent);
          }
      }
   }

See what my hint meant now?

Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.