3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <!DOCTYPE html> <html> <head> <title></title> </head> <body> <table class="table-list table table-responsive table-striped" border="1"> <thead> <tr> <th class="coll-1 name">name</th> <th class="coll-2">height</th> <th class="coll-3">weight</th> <th class="coll-date">date</th> <th class="coll-4"><span class="info">info</span></th> <th class="coll-5">country</th> </tr> </thead> <tbody> <tr> <td class="coll-1 name"> <a href="/username/Jhon Doe/" class="icon"><i class="flaticon-user"></i></a> <a href="/username/Jhon Doe/">Jhon Doe</a> </td> <td class="coll-2 height">45</td> <td class="coll-3 weight">50</td> <td class="coll-date">9am May. 16th</td> <td class="coll-4 size mob-info">abcd</td> <td class="coll-5 country"><a href="/country/CA/">CA</a></td> </tr> <tr> <td class="coll-1 name"> <a href="/username/Kasim Shk/" class="icon"><i class="flaticon-user"></i></a> <a href="/username/Kasim Shk/">Kasim Shk</a> </td> <td class="coll-2 height">33</td> <td class="coll-3 weight">54</td> <td class="coll-date">Mar. 14th '18</td> <td class="coll-4 size mob-info">ijkl</td> <td class="coll-5 country"><a href="/country/UAE/">UAE</a></td> </tr> </tbody> </table> </body> </html> HTML; $dom = new DOMDocument; $dom->loadHTML($html); $xpath = new DOMXPath($dom); foreach ($xpath->query('//tbody/tr') as $tr) { $tmp = []; // reset the temporary array so previous entries are removed foreach ($xpath->query("td[@class]", $tr) as $td) { $key = preg_match('~[a-z]+$~', $td->getAttribute('class'), $out) ? $out[0] : 'no_class'; if ($key === "name") { $tmp['user_link'] = $xpath->query("a[@class = 'icon']", $td)[0]->getAttribute('href'); } $tmp[$key] = trim($td->textContent); } $tmp['date'] = date("M. dS 'y", strtotime(preg_replace('~\.|\d+[ap]m *~', '', $tmp['date']))); $result[] = $tmp; } var_export($result); echo "\n----\n"; echo json_encode($result);
Output for git.master, git.master_jit
/bin/php-git-master: error while loading shared libraries: libonig.so.5: cannot open shared object file: No such file or directory
Process exited with code 127.
Output for rfc.property-hooks
array ( 0 => array ( 'user_link' => '/username/Jhon Doe/', 'name' => 'Jhon Doe', 'height' => '45', 'weight' => '50', 'date' => 'May. 16th \'23', 'info' => 'abcd', 'country' => 'CA', ), 1 => array ( 'user_link' => '/username/Kasim Shk/', 'name' => 'Kasim Shk', 'height' => '33', 'weight' => '54', 'date' => 'Jan. 01st \'70', 'info' => 'ijkl', 'country' => 'UAE', ), ) ---- [{"user_link":"\/username\/Jhon Doe\/","name":"Jhon Doe","height":"45","weight":"50","date":"May. 16th '23","info":"abcd","country":"CA"},{"user_link":"\/username\/Kasim Shk\/","name":"Kasim Shk","height":"33","weight":"54","date":"Jan. 01st '70","info":"ijkl","country":"UAE"}]

This tab shows result from various feature-branches currently under review by the php developers. Contact me to have additional branches featured.

Active branches

Archived branches

Once feature-branches are merged or declined, they are no longer available. Their functionality (when merged) can be viewed from the main output page


preferences:
55.35 ms | 408 KiB | 5 Q