3v4l.org

run code in 300+ PHP versions simultaneously
<?php $html = <<<HTML <h5>Work Experience</h5> <p><span id="organization">Company Name 1</span></p> Designation 1 <p>Date 1 </p> <ul> <li>Some text 1</li> </ul> <p><span id="organization">Company Name 2</span></p> Designation 2 <p>Date 2 </p> <ul> <li>Some text 2</li> </ul> <p><span id="organization">Company Name 3</span></p> Designation 3 <p>Date 3 </p> <ul> <li>Some text 3</li> </ul></div> HTML; $doc = new DOMDocument(); $doc->loadHTML($html); $spans = $doc->getElementsByTagName('span'); foreach ($spans as $span) { if ($span->hasAttribute('id') && $span->getAttribute('id') === 'organization') { var_dump($span->nodeValue); } }
Output for git.master, git.master_jit, rfc.property-hooks
Warning: DOMDocument::loadHTML(): ID organization already defined in Entity, line: 9 in /in/XdrQ1 on line 29 Warning: DOMDocument::loadHTML(): ID organization already defined in Entity, line: 16 in /in/XdrQ1 on line 29 Warning: DOMDocument::loadHTML(): Unexpected end tag : div in Entity, line: 22 in /in/XdrQ1 on line 29 string(14) "Company Name 1" string(14) "Company Name 2" string(14) "Company Name 3"

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:
28.28 ms | 406 KiB | 5 Q