3v4l.org

run code in 300+ PHP versions simultaneously
<?php function get_jobs() { return json_decode('[ {"id":"28038a67e70c7e235fa725bbf8b6e167d9e3efee1e43a304d73be8408c6f24a2","posting_job_title":"Entry Level Sales Representative*","job_relationship":"w2_employee","location":"Aston, PA","territory_id":1,"territory_abbr":"PHL"}, {"id":"7f8bcb16e0f3ffe9c8ce9aff2b6033bfbe582241e818aaf9c21506d509e70592","posting_job_title":"Sales Representative*","job_relationship":"w2_employee","location":"Chester, PA","territory_id":1,"territory_abbr":"PHL"}, {"id":"7c6cc1c2abda3dae2edf0982f758073316491b27c240e5fa13df791e0fb5b744","posting_job_title":"Entry Level Sales Representative*","job_relationship":"w2_employee","location":"Aston, PA","territory_id":1,"territory_abbr":"PHL"}, {"id":"556b7ec84be0e6a5130cde5a441dc58ed595de5acd4e5f4883a2b2e6cc5eb4f4","posting_job_title":"Siding Subcontractors Needed- Up To $10,000 SIGN ON BONUS","job_relationship":"company","location":"Essex, MD","territory_id":3,"territory_abbr":"MD"}, {"id":"31f1752e8c3f1086b4a1ed499e8786e1d15a8d1825cb75848056333d1cae8276","posting_job_title":"Entry Level Sales Representative*","job_relationship":"w2_employee","location":"Bridgewater, NJ","territory_id":2,"territory_abbr":"NJ"}, {"id":"197c35000fb9b9ca1fe71771bb618c5443f0e7e51b59b9cad22f08d77d73de54","posting_job_title":"Siding Subcontractors Needed- Up To $10,000 SIGN ON BONUS","job_relationship":"company","location":"Aberdeen, MD","territory_id":3,"territory_abbr":"MD"}, {"id":"8621ae18266b571175358113fd3ed7147f2ffa7d248c71c8e1a78b566ac24628","posting_job_title":"Sales Representative*","job_relationship":"w2_employee","location":"Bronx, NY","territory_id":4,"territory_abbr":"CT"}, {"id":"bc2f7034687d2273f14bb2fa41fef8472f5e12ce8e483210b628167bba09c9aa","posting_job_title":"Sales Representative*","job_relationship":"w2_employee","location":"Greenwich, CT","territory_id":4,"territory_abbr":"CT"}, {"id":"5debdc91afd45080a7cb87912b9411f186793e3ad9be8fbf8fe7f40f85ce9d17","posting_job_title":"Entry Level Sales Representative*","job_relationship":"w2_employee","location":"Bayside, NY","territory_id":5,"territory_abbr":"LI"}, {"id":"3dc256cecd93030f3d4079b5a313277cc03f92fb2d991cf9b0b656a34f84425f","posting_job_title":"Entry Level Sales Representative*","job_relationship":"w2_employee","location":"Bayside, NY","territory_id":5,"territory_abbr":"LI"}, {"id":"8121cb7efb0e04130fbdc3f69468c7434c1582f71d71408ef689b81519d86a5c","posting_job_title":"Siding Subcontractors Needed- Up To $10,000 SIGN ON BONUS","job_relationship":"company","location":"Parkville, MD","territory_id":3,"territory_abbr":"MD"}, {"id":"269e4edc7ed745210c71e8b324a5f2f559ba793f1ff67d5e61b00ee48b992d89","posting_job_title":"Sales Representative*","job_relationship":"w2_employee","location":"Bayside, NY","territory_id":5,"territory_abbr":"LI"} ]', true); } function display_jobs() { $jobs = get_jobs(); usort($jobs, fn($a, $b) => $a['territory_id'] <=> $b['territory_id'] ?: $a['location'] <=> $b['location'] ); $groups = []; foreach ($jobs as $posting) { $groups[$posting['territory_abbr']][$posting['location']][] = $posting; } $html = ''; foreach ($groups as $terrAbbr => $locations) { $html .= <<<HTML <div style="border: solid 1px orange;"> <h3>$terrAbbr</h3> HTML; foreach ($locations as $locName => $postings) { $html .= <<<HTML <div style="border: solid 1px blue;"> <h4>$locName</h4> HTML; foreach ($postings as $posting) { $html .= sprintf(<<<HTML <div style="border: solid 1px green;"> <ul class="col"> <li>%s</li> <li>%s</li> <li>%s</li> <li>%s</li> <li>%s</li> <li>%s</li> </ul> </div> HTML, $posting['territory_abbr'], $posting['territory_id'], $posting['location'], $posting['id'], $posting['posting_job_title'], $posting['job_relationship'] ); } $html .= <<<HTML </div> HTML; } $html .= <<<HTML </div> HTML; } $html = $html ?: 'No data'; return <<<HTML <div style="border: solid 1px red;"> $html </div> HTML; } echo display_jobs();

Abusive script

This script was stopped while abusing our resources


preferences:
74.41 ms | 406 KiB | 5 Q