How can i get particular fields in the array using foreach

前端 未结 2 1423
不知归路
不知归路 2020-12-22 08:24

I wanted to take the fields such as School Type, Name, Location, Details, Degreemjor, Education details, Start and End Date

How can i do this using the foreach loop

2条回答
  •  心在旅途
    2020-12-22 09:03

    I'm an idiot, it didn't click that that was XML. Okay, so your array appears to be an array of schools/institutions from a resume, correct? Just follow the XML hierarchy to reach each node that you care about.

    foreach ($nodes as $node) {
        echo "Type: " . $node->attributes()['SchoolType'] . "\n";
        echo "Name: " . $node->School->SchoolName . "\n";
        echo "Location: " . $node->SchoolLocation . "\n";
        echo "Degree name: " . $node->Degree->DegreeName . "\n";
        // etc
    }
    

提交回复
热议问题