This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| libxml_use_internal_errors(true); | |
| $document = new DomDocument(); | |
| $document->loadXML(''); | |
| ?> | |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $p = $document->createElement('p', 'foobar'); | |
| $elements = $document->getElementsByTagName('p'); | |
| $lastElement = $elements[$elements->length - 1]; | |
| if($lastElement->nextSibling) { | |
| $elements->insertBefore($p, $lastElement->nextSibling); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $user = function($name) { | |
| $me = array(); | |
| $me['name'] = NULL; | |
| $me['init'] = function($name) use(&$me) { | |
| $me['name'] = $name; | |
| return $me; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $user = function($name) { | |
| $me = array( | |
| 'name' => NULL, | |
| 'init' => function($name) use(&$me) { | |
| $me['name'] = $name; | |
| return $me; | |
| }, | |
| 'whoami' => function() use(&$me) { |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class LineIterator { | |
| protected $handle; | |
| public function __construct($file) { | |
| $this->handle = fopen($file, 'r'); | |
| } | |
| public function __invoke() { | |
| return fgets($this->handle); | |
| } |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| function LineIterator($file) { | |
| $handle = fopen($file, 'r'); | |
| return function() use($handle) { | |
| if(!feof($handle)) { | |
| return fgets($handle); | |
| } | |
| fclose($handle); | |
| }; |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| preg_match_all('<(?P<key>\w+)\:(?P<value>\d+)>', 'foo:23,bar:42', $matches); | |
| var_dump($matches); | |
| array(5) { | |
| [0]=> | |
| array(2) { | |
| [0]=> | |
| string(6) "foo:23" |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $curl = curl_init(); | |
| curl_setopt_array($curl, array( | |
| CURLOPT_RETURNTRANSFER => true, | |
| CURLOPT_URL => 'https://sts.idm.telekom.com/rest-v1/tokens/odg', | |
| CURLOPT_HTTPAUTH => CURLAUTH_BASIC, | |
| CURLOPT_USERPWD => '' | |
| )); | |
| $response = json_decode(curl_exec($curl)); |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| $content = ' | |
| <table><tr><td>00:00:00</td><td>Anfang</td></tr><tr><td>00:00:07</td><td>Mit Marcel</td></tr><tr> | |
| <td>00:00:16</td><td>und Martin</td></tr><tr><td>00:00:41</td><td>Tiny Wings</td></tr><tr><td>00:03:53</td><td> | |
| <a href="http://dealbook.nytimes.com/2012/07/16/googles-marissa-mayer-tapped-as-yahoos-chief/?hp&pagewanted=all" | |
| target="_blank">Marissa Mayer wir Yahoo CEO</td></tr><tr><td>00:10:20</td><td><a href="http://dearmarissamayer.com" | |
| target="_blank">dearmarissamayer.com</td></tr><tr><td>00:13:01</td><td><a | |
| href="https://hacks.mozilla.org/2012/07/firefox-beta-15-supports-the-new-opus-audio-format/" target="_blank">Firefox |
This file contains hidden or bidirectional Unicode text that may be interpreted or compiled differently than what appears below. To review, open the file in an editor that reveals hidden Unicode characters.
Learn more about bidirectional Unicode characters
| <?php | |
| class RecursiveDOMIterator extends RecursiveArrayIterator { | |
| public function __construct($node) { | |
| parent::__construct(iterator_to_array($node->childNodes)); | |
| } | |
| public function getChildren() { | |
| return new self($this->current()); | |
| } | |
| public function hasChildren() { |