run code in 150+ php & hhvm versions
Bugs & Features
<?php $json = '{"nodes":[{"top_id":"1","top":"1","parent_id":"2","parent":"2","child_id":"5","child":"5","standard":"Standard I: Curriculum, Planning, and Assessment","indicator":"Indicator I-A.\tCurriculum &amp; Planning","element":"I-A-1. Subject Matter Knowledge","Connections":"Common Core\r\n2011 Mass Frameworks","Effective Practice":"Accurately presents content identified in the state frameworks for the given grade level\r\nMakes connections across ideas and content areas","Proficient":"Demonstrates sound knowledge and understanding of the subject matter and the pedagogy it requires by consistently engaging students in learning experiences that enable them to acquire complex knowledge and skills in the subject.","Suggested Artifacts":"Curriculum units\r\nPlan book\r\nPhotographs\r\nPlan book, pictures, video"},{"top_id":"1","top":"1","parent_id":"2","parent":"2","child_id":"6","child":"6","standard":"Standard I: Curriculum, Planning, and Assessment","indicator":"Indicator I-A.\tCurriculum &amp; Planning","element":"I-A-2. Child and Adolescent Development","Connections":"Differentiated Instruction","Effective Practice":"Delivers instruction using language comprehensible to students\r\nProvides resources and assessments at appropriate challenge levels","Proficient":"Demonstrates knowledge of the developmental levels of students in the classroom and the different ways these students learn by providing differentiated learning experiences that enable all students to progress toward meeting intended outcomes.","Suggested Artifacts":"Plan book, pictures, video\r\nCopies of resources, assessments"},{"top_id":"1","top":"1","parent_id":"2","parent":"2","child_id":"7","child":"7","standard":"Standard I: Curriculum, Planning, and Assessment","indicator":"Indicator I-A.\tCurriculum &amp; Planning","element":"I-A-3. Rigorous Standards-Based Unit Design","Connections":"Understanding by Design (UbD)\r\nBloom&#039;s Taxonomy\r\n\r\nModel Curriculum Units","Effective Practice":"Formative and summative assessment is evident\r\nAll lessons move toward the unit learning objectives","Proficient":"Designs units of instruction with measurable outcomes and challenging tasks requiring higher-order thinking skills that enable students to learn the knowledge and skills defined in state standards/local curricula.","Suggested Artifacts":"Curriculum unit, video, student work"},{"top_id":"1","top":"1","parent_id":"2","parent":"2","child_id":"8","child":"8","standard":"Standard I: Curriculum, Planning, and Assessment","indicator":"Indicator I-A.\tCurriculum &amp; Planning","element":"I-A-4. Well-Structured Lessons","Connections":"Understanding by Design (UbD)\r\nUniversal Design for learning (UDL)","Effective Practice":"Includes learning objectives\r\nDifferentiates to meet diverse needs and learning styles","Proficient":"Develops well-structured lessons with challenging, measurable objectives and appropriate student engagement strategies, pacing, sequence, activities, materials, resources, technologies, and grouping.","Suggested Artifacts":"Plan book, lesson plan, video"},{"top_id":"1","top":"1","parent_id":"3","parent":"3","child_id":"9","child":"9","standard":"Standard I: Curriculum, Planning, and Assessment","indicator":"Indicator I-B. Assessment","element":"I-B-1. Variety of Assessment Methods","Connections":"Massachusetts Tiered System of Support (MTSS)","Effective Practice":"Uses range of formative and summative assessments\r\nMeasures student growth toward standards","Proficient":"Designs and administers a variety of informal and formal methods and assessments, including common interim assessments, to measure each student&#039;s learning, growth, and progress toward achieving state/local standards.","Suggested Artifacts":"Formative, interim, or summative assessments"},{"top_id":"1","top":"1","parent_id":"3","parent":"3","child_id":"10","child":"10","standard":"Standard I: Curriculum, Planning, and Assessment","indicator":"Indicator I-B. Assessment","element":"I-B-2. Adjustment to Practice","Connections":"Professional Learning Communities\r\nData Teams","Effective Practice":"Groups students after formative assessments and/or data analysis\r\nParticipates in data team meetings\r\nAdjusts pace according to student needs","Proficient":"Organizes and analyzes results from a variety of assessments to determine progress toward intended outcomes and uses these findings to adjust practice and identify and/or implement appropriate differentiated interventions and enhancements for students.","Suggested Artifacts":"Lesson plan revised in response to assessment\r\nPre- and post assessments"},{"top_id":"1","top":"1","parent_id":"4","parent":"4","child_id":"11","child":"11","standard":"Standard I: Curriculum, Planning, and Assessment","indicator":"Indicator I-C. Analysis","element":"I-C-1. Analysis and Conclusions","Connections":"Data Teams\r\nPLCs","Effective Practice":"Views wide range of data\r\nDraws conclusions to improve student learning","Proficient":"Individually and with colleagues, draws appropriate conclusions from a thorough analysis of a wide range of assessment data to improve student learning.","Suggested Artifacts":"Data printouts or graphic representations\r\nTeam meeting notes"},{"top_id":"1","top":"1","parent_id":"4","parent":"4","child_id":"12","child":"12","standard":"Standard I: Curriculum, Planning, and Assessment","indicator":"Indicator I-C. Analysis","element":"I-C-2. Sharing Conclusions With Colleagues","Connections":"Data Teams\r\nPLCs","Effective Practice":"Shares student learning conclusions with colleagues\r\nSeeks feedback about practices that will improve student learning","Proficient":"Regularly shares with appropriate colleagues (e.g., general education, special education, and English learner staff) conclusions about student progress and seeks feedback from them about instructional or assessment practices that will support improved student learning.","Suggested Artifacts":"Meeting notes\r\nRevised lesson or unit plans"},{"top_id":"1","top":"1","parent_id":"4","parent":"4","child_id":"13","child":"13","standard":"Standard I: Curriculum, Planning, and Assessment","indicator":"Indicator I-C. Analysis","element":"I-C-3. Sharing Conclusions With Students","Connections":null,"Effective Practice":"Provides feedback to students about improving performance\r\nProvides feedback to families about improving student performance","Proficient":"Based on assessment results, provides descriptive feedback and engages students and families in constructive conversation that focuses on how students can improve their performance.","Suggested Artifacts":"Conference notes, videotaped conference\r\nConference notes, email, newsletters"}]}'; $array = json_decode($json, true); $nodes = $array['nodes']; $tree = array(); foreach ($nodes as $item) { // construct our tree // gather the data if ( !isset($data_by_id[ $item['top_id'] ])) { $data_by_id[ $item['top_id'] ] = array( 'name' => $item['standard'] ); } if ( !isset($data_by_id[ $item['parent_id'] ])) { $data_by_id[ $item['parent_id'] ] = array( 'name' => $item['indicator'] ); } if ( !isset($data_by_id[ $item['child_id'] ])) { $data_by_id[ $item['child_id'] ] = array( 'name' => $item['element'], 'contents' => array($item['Connections'], $item['Effective Practice'], $item['Proficient'], $item['Suggested Artifacts']) ); } // construct the tree if (! isset($tree[ $item['top_id'] ]) { $tree[ $item['top_id'] ][ $item['parent_id'] ][ $item['child_id'] ] = 1; } elseif (! isset($tree[ $item['top_id'] ][$item['parent_id']]) { $tree[ $item['top_id'] ][ $item['parent_id'] ][ $item['child_id'] ] = 1; } elseif (in_array([ $item['child_id'] ], $tree[ $item['top_id'] ][ $item['parent_id'] ])) { $tree[ $item['top_id'] ][ $item['parent_id'] ][ $item['child_id'] ]++; } else { $tree[ $item['top_id'] ][ $item['parent_id'] ][] = array( $item['child_id'] ] => 1 ); } } print_r($tree); /* print_r($data_by_id); echo "\n\n"; function print_tree( $data, $arr ){ echo "<ul>\n"; foreach ($arr as $key => $value) { echo "<li>" . $data[$key]['name'] . "</li>\n"; if (isset($data[$key]['contents']) && is_array($data[$key]['contents'])) { echo '<ul>'; foreach ($data[$key]['contents'] as $leaf) { echo '<li>' . $leaf . "</li>\n"; } echo "</ul>\n"; } if (is_array($value)) { print_tree($data, $value); } } echo "</ul>\n"; } print_tree($data_by_id, $tree); */ // go through the tree and print the info echo "<ul>\n"; foreach ($tree as $trunk => $trunk_val) { echo '<li>' . $data_by_id[ $trunk ]['name'] . "</li>\n"; echo "<ul>\n"; foreach ($trunk_val as $branch => $branch_val) { echo '<li>' . $data_by_id[ $branch ]['name'] . "</li>\n"; echo "<ul>\n"; foreach ($branch_val as $twig => $twig_val) { echo '<li>' . $data_by_id[ $twig ]['name'] . "</li>\n"; if (isset($data_by_id[$twig]['contents']) && is_array($data_by_id[$twig]['contents'])) { echo '<ul>'; foreach ($data_by_id[$twig]['contents'] as $leaf) { echo '<li>' . $leaf . "</li>\n"; } echo "</ul>\n"; } } echo "</ul>\n"; } echo "</ul>\n"; } echo "</ul>\n";
based on 7MVV8
Output for 4.4.2 - 4.4.9, 5.1.0 - 5.6.21, 7.0.0 - 7.1.0RC4
Parse error: syntax error, unexpected '{' in /in/vdYiJ on line 22
Process exited with code 255.
Output for hhvm-3.10.0 - 3.12.0
Fatal error: syntax error, unexpected '{' in /in/vdYiJ on line 22
Process exited with code 255.
Output for 4.3.0 - 4.3.1, 4.3.5 - 4.4.1, 5.0.0 - 5.0.5
Parse error: parse error, unexpected '{' in /in/vdYiJ on line 22
Process exited with code 255.
Output for 4.3.2 - 4.3.4
Parse error: parse error in /in/vdYiJ on line 22
Process exited with code 255.