This file contains 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 TailRecursion { | |
private $_function = NULL; | |
private $_arguments = array(); | |
private $_recursing = FALSE; | |
private $_recursion = NULL; | |
public function __construct(Callable $function) { |
This file contains 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 | |
$data = <<<XML | |
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<element> | |
<title>ein Titel</title> | |
<content>Ein Inhalt</content> | |
<content> | |
Ein Inhalt mit | |
<subcontent att1="Hallo">Subnodes</subcontent> und weiterem Text, |
This file contains 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 | |
$data = <<<XML | |
<?xml version="1.0" encoding="ISO-8859-1"?> | |
<element> | |
<title>ein Titel</title> | |
<content>Ein Inhalt</content> | |
<content> | |
Ein Inhalt mit | |
<subcontent att1="Hallo">Subnodes</subcontent> und weiterem Text, |
This file contains 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 | |
$data = array( | |
array('id' => 1, 'title' => 'Top 2'), | |
array('id' => 2, 'title' => '2. Entry'), | |
array('id' => 3, 'title' => 'Top 1'), | |
array('id' => 4, 'title' => '1. Entry') | |
); | |
usort( |
This file contains 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 | |
$data = <<<XML | |
<sample> | |
<content>Inhalt Eins</content> | |
<content>Inhalt <b>Zwei</b></content> | |
</sample> | |
XML; | |
$dom = new DOMDocument(); |
This file contains 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 | |
/** | |
* Shows how to highlight several words in the body of a html document. It adds spans with specified | |
* classes around the found words/word parts. | |
* | |
* @version $Id: highlightWords.php 444 2010-05-10 09:29:49Z subjective $ | |
* @license http://www.opensource.org/licenses/mit-license.php The MIT License | |
* @copyright Copyright (c) 2009 Bastian Feder, Thomas Weinert | |
*/ |
This file contains 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 | |
/* | |
* Sample for Blog Entry: | |
* http://www.a-basketful-of-papayas.net/2010/04/using-php-dom-with-xpath.html | |
*/ | |
$errorSetting = libxml_use_internal_errors(TRUE); | |
$feed = new DOMDocument(); | |
$feed->load('http://www.a-basketful-of-papayas.net/feeds/posts/default'); | |
libxml_clear_errors(); |
This file contains 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 | |
$xml = file_get_contents('php://stdin'); | |
class MyXpath extends DOMXpath { | |
private static $_context = null; | |
public function __construct($document) { | |
parent::__construct($document); |
This file contains 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 MySimpleXMLElement extends SimpleXMLElement { | |
public function addChild($name, $value = null, $namespace = null) { | |
$result = parent::addChild($name, null, $namespace); | |
if (isset($value)) { | |
$node = dom_import_simplexml($result); | |
$node->appendChild($node->ownerDocument->createTextNode($value)); | |
} |
This file contains 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 | |
$xml = <<<'XML' | |
<root attribute="42"></root> | |
XML; | |
$dom = new DOMDocument(); | |
$dom->preserveWhiteSpace = FALSE; | |
$dom->loadXml($xml); |