我怎样才能在使用数组的foreach特定领域 [英] How can i get particular fields in the array using foreach

查看:113
本文介绍了我怎样才能在使用数组的foreach特定领域的处理方法,对大家解决问题具有一定的参考价值,需要的朋友们下面随着小编来一起学习吧!

问题描述

我想借此领域,如学校类型,名称,位置,细节,Degreemjor,教育信息,开始和结束日期

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

我怎样才能做到这一点使用foreach循环?

How can i do this using the foreach loop ?

这是我的数组。

    Array (
    [0] => SimpleXMLElement Object (
    [@attributes] => Array (
    [SchoolType] => UnSpecified
    )
    [School] => SimpleXMLElement Object (
    [SchoolName] => School of
    )
    [SchoolLocation] => SimpleXMLElement Object (
    )
    [Degree] => SimpleXMLElement Object (
    [@attributes] => Array (
    [DegreeType] =>
    )
    [IsHighestDegee] => True
    [DegreeName] => SimpleXMLElement Object (
    )
    [DegreeDate] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    [DegreeMajor] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    [EducationDetails] => SimpleXMLElement Object (
    )
    [DegreeMeasure] => SimpleXMLElement Object (
    [EducationMeasure] => SimpleXMLElement Object (
    [MeasureSystem] => SimpleXMLElement Object (
    )
    [MeasureValue] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    )
    )
    [DateofAttendance] => SimpleXMLElement Object (
    [StartDate] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    [EndDate] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    )
    [EducationDescription] => Editor - School of Business Management Students\' newsletter
    )
    )
    [1] => SimpleXMLElement Object (
    [@attributes] => Array (
    [SchoolType] => UnSpecified
    )
    [School] => SimpleXMLElement Object (
    [SchoolName] => Nanyang Polytechnic
    )
    [SchoolLocation] => Nanyang
    [Degree] => SimpleXMLElement Object (
    [@attributes] => Array (
    [DegreeType] => Certificate Courses
    )
    [IsHighestDegee] => False
    [DegreeName] => SimpleXMLElement Object (
    )
    [DegreeDate] => SimpleXMLElement Object (
    [AnyDate] => 1/1/1999
    )
    [DegreeMajor] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    [EducationDetails] => Engineering
    [DegreeMeasure] => SimpleXMLElement Object (
    [EducationMeasure] => SimpleXMLElement Object (
    [MeasureSystem] => SimpleXMLElement Object (
    )
    [MeasureValue] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    )
    )
    [DateofAttendance] => SimpleXMLElement Object (
    [StartDate] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    [EndDate] => SimpleXMLElement Object (
    [AnyDate] => 1/1/1999
    )
    )
    [EducationDescription] => Secretary - Nanyang Polytechnic Students\' Union Participated in inter-diploma debate (
    1999
    ) - preliminary and semi-final
    )
    )
    [2] => SimpleXMLElement Object (
    [@attributes] => Array (
    [SchoolType] => UnSpecified
    )
    [School] => SimpleXMLElement Object (
    [SchoolName] => Member of school volleyball team - represented school in National competition
    )
    [SchoolLocation] => SimpleXMLElement Object (
    )
    [Degree] => SimpleXMLElement Object (
    [@attributes] => Array (
    [DegreeType] => Certificate Courses
    )
    [IsHighestDegee] => False
    [DegreeName] => SimpleXMLElement Object (
    )
    [DegreeDate] => SimpleXMLElement Object (
    [AnyDate] => 1/1/1996
    )
    [DegreeMajor] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    [EducationDetails] => Engineering
    [DegreeMeasure] => SimpleXMLElement Object (
    [EducationMeasure] => SimpleXMLElement Object (
    [MeasureSystem] => SimpleXMLElement Object (
    )
    [MeasureValue] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    )
    )
    [DateofAttendance] => SimpleXMLElement Object (
    [StartDate] => SimpleXMLElement Object (
    [0] => SimpleXMLElement Object (
    )
    )
    [EndDate] => SimpleXMLElement Object (
    [AnyDate] => 1/1/1996
    )
    )
    [EducationDescription] => Patrol Leader - Girl Guides Member of school volleyball team - represented school in National competition - clinched 2nd prize in 1996
    )
    )
    )

下面是 var_export

array (
0 => SimpleXMLElement::__set_state(
array(
\'@attributes\' => array (
\'SchoolType\' => \'UnSpecified\',
), \'School\' => SimpleXMLElement::__set_state(
array(
\'SchoolName\' => \'School of\',
)
), \'SchoolLocation\' => SimpleXMLElement::__set_state(
array(
)
), \'Degree\' => SimpleXMLElement::__set_state(
array(
\'@attributes\' => array (
\'DegreeType\' => \'\',
), \'IsHighestDegee\' => \'True\', \'DegreeName\' => SimpleXMLElement::__set_state(
array(
)
), \'DegreeDate\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
),
)
), \'DegreeMajor\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
), )), \'EducationDetails\' => SimpleXMLElement::__set_state(
array(
)), \'DegreeMeasure\' => SimpleXMLElement::__set_state(
array(
\'EducationMeasure\' => SimpleXMLElement::__set_state(
array(
\'MeasureSystem\' => SimpleXMLElement::__set_state(
array(
)
), \'MeasureValue\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
),
)), )), )), \'DateofAttendance\' => SimpleXMLElement::__set_state(
array(
\'StartDate\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
),
)), \'EndDate\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
), )), )), \'EducationDescription\' => \'Editor - School of Business Management Students\\\' newsletter\', )), )), 1 => SimpleXMLElement::__set_state(
array(
\'@attributes\' => array (
\'SchoolType\' => \'UnSpecified\',
), \'School\' => SimpleXMLElement::__set_state(
array(
\'SchoolName\' => \'Nanyang Polytechnic\',
)
), \'SchoolLocation\' => \'Nanyang\', \'Degree\' => SimpleXMLElement::__set_state(
array(
\'@attributes\' => array (
\'DegreeType\' => \'Certificate Courses\',
), \'IsHighestDegee\' => \'False\', \'DegreeName\' => SimpleXMLElement::__set_state(
array(
)
), \'DegreeDate\' => SimpleXMLElement::__set_state(
array(
\'AnyDate\' => \'1/1/1999\',
)), \'DegreeMajor\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
), )), \'EducationDetails\' => \'Engineering\', \'DegreeMeasure\' => SimpleXMLElement::__set_state(
array(
\'EducationMeasure\' => SimpleXMLElement::__set_state(
array(
\'MeasureSystem\' => SimpleXMLElement::__set_state(
array(
)
), \'MeasureValue\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
),
)), )), )), \'DateofAttendance\' => SimpleXMLElement::__set_state(
array(
\'StartDate\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
),
)), \'EndDate\' => SimpleXMLElement::__set_state(
array(
\'AnyDate\' => \'1/1/1999\',
)), )), \'EducationDescription\' => \'Secretary - Nanyang Polytechnic Students\\\' Union Participated in inter-diploma debate (
1999
) - preliminary and semi-final\', )), )), 2 => SimpleXMLElement::__set_state(
array(
\'@attributes\' => array (
\'SchoolType\' => \'UnSpecified\',
), \'School\' => SimpleXMLElement::__set_state(
array(
\'SchoolName\' => \'Member of school volleyball team - represented school in National competition\',
)
), \'SchoolLocation\' => SimpleXMLElement::__set_state(
array(
)), \'Degree\' => SimpleXMLElement::__set_state(
array(
\'@attributes\' => array (
\'DegreeType\' => \'Certificate Courses\',
), \'IsHighestDegee\' => \'False\', \'DegreeName\' => SimpleXMLElement::__set_state(
array(
)
), \'DegreeDate\' => SimpleXMLElement::__set_state(
array(
\'AnyDate\' => \'1/1/1996\',
)), \'DegreeMajor\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
), )), \'EducationDetails\' => \'Engineering\', \'DegreeMeasure\' => SimpleXMLElement::__set_state(
array(
\'EducationMeasure\' => SimpleXMLElement::__set_state(
array(
\'MeasureSystem\' => SimpleXMLElement::__set_state(
array(
)
), \'MeasureValue\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
),
)), )), )), \'DateofAttendance\' => SimpleXMLElement::__set_state(
array(
\'StartDate\' => SimpleXMLElement::__set_state(
array(
0 => SimpleXMLElement::__set_state(
array(
)
),
)), \'EndDate\' => SimpleXMLElement::__set_state(
array(
\'AnyDate\' => \'1/1/1996\',
)), )), \'EducationDescription\' => \'Patrol Leader - Girl Guides Member of school volleyball team - represented school in National competition - clinched 2nd prize in 1996\', )), )), )

这是跟进的<一个href=\"http://stackoverflow.com/questions/30276031/how-can-i-take-the-values-from-this-array\">this问题

推荐答案

有一个看的的SimpleXMLElement ::属性

我认为你可以得到像

$url = 'http://recruitplushrxmlapidemo.onlineresumeparser.com/hrxml/153Melanie%20R.%20Mather%20Mills.xml';

$sxml = simplexml_load_file($url);

foreach($sxml->StructuredXMLResume->EducationHistory->SchoolOrInstitution as $key => $value){

    echo 'SchoolType --> '.$value->attributes()['SchoolType'];        
    echo "<br />";
    echo 'SchoolName --> '.$value->School->SchoolName;
    echo "<br />";
    echo 'SchoolLocation --> '.$value->SchoolLocation;
    echo "<br />";
    echo 'DegreeMajor --> '.$value->Degree->DegreeMajor[0];
    echo "<br />";
    echo 'EducationDetails --> '.$value->Degree->EducationDetails;
    echo "<br />";
    echo 'StartDate --> '.$value->Degree->DateofAttendance->StartDate[0];
    echo "<br />";
    echo 'EndDate --> '.$value->Degree->DateofAttendance->EndDate->AnyDate;
    echo "<br /><br />";

}

这篇关于我怎样才能在使用数组的foreach特定领域的文章就介绍到这了,希望我们推荐的答案对大家有所帮助,也希望大家多多支持IT屋!

查看全文
登录 关闭
扫码关注1秒登录
发送“验证码”获取 | 15天全站免登陆