$education = $user->education;
Array ( [0] => stdClass Object ( [school] => stdClass Object ( [id] => 112629628784911 [name] => Vardhman Shiksha Mandir ) [year] => stdClass Object ( [id] => 136328419721520 [name] => 2009 ) [type] => High School ) [1] => stdClass Object ( [school] => stdClass Object ( [id] => 115934828416686 [name] => jamia hamdrad ) [concentration] => Array ( [0] => stdClass Object ( [id] => 187549374618419 [name] => B.Tech Computer Science ) ) [type] => College ) [2] => stdClass Object ( [school] => stdClass Object ( [id] => 133233016699548 [name] => Hamdard University ) [type] => College [classes] => Array ( [0] => stdClass Object ( [id] => 196267900399898 [name] => 2nd year [with] => Array ( [0] => stdClass Object ( [id] => 553736429 [name] => Ahmed Abdul Zahra ) ) [from] => stdClass Object ( [id] => 553736429 [name] => Ahmed Abdul Zahra ) ) ) ) [3] => stdClass Object ( [school] => stdClass Object ( [id] => 104008189635968 [name] => Jamia Hamdard ) [year] => stdClass Object ( [id] => 138879996141011 [name] => 2013 ) [type] => Graduate School ) )
我试过用嵌套的foreach循环迭代它..
foreach($education as $educationFirstArray){
foreach($educationFirstArray as $educationSecondArray){
foreach($educationSecondArray as $key=>$value){
echo "<strong>".$key."</strong> -> ".$value."<br/>";
}
}
}
输出:
id -> 112629628784911
name -> Vardhman Shiksha Mandir
id -> 136328419721520
name -> 2009
Warning: Invalid argument supplied for foreach() in index.php on line 73
id -> 115934828416686
name -> jamia hamdrad
Catchable fatal error: Object of class stdClass could not be converted to string in index.php on line 74
任何有关使该数组高于迭代的帮助都将非常可观,在此先感谢..