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 | |
/** | |
* 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 | |
$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 | |
$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 | |
<?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 | |
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
SELECT * | |
FROM mytable | |
WHERE idfield IN ( | |
SELECT MAX(main.idfield) | |
FROM mytable AS main | |
JOIN ( | |
SELECT groupfield, MAX(maxfield) maximum | |
FROM mytable | |
GROUP BY groupfield | |
ORDER BY maximum DESC |
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 = '<div>blabla<h1><a href="http://www.example.com/blabla.php?id=12345" class=l>blub</a></h1><h2><a href="http://www.example.com/asfadfafadf.php?id=12345" class=l>blub</a></h2>sdfafgdghaghagh<h1><a href="http://www.example.com/fdgadfhfh.php?id=123dsfasdf45" class=l>blub</a>asdfasdfasdf</h1>'; | |
$doc = new DOMDocument(); | |
$doc->loadHTML($data); | |
$xpath = new DOMXpath($doc); | |
$linkTargets = array(); | |
foreach ($xpath->evaluate('//*[@href]/@href', NULL, FALSE) as $attribute) { | |
$linkTargets[] = $attribute->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 | |
include('../../src/Carica/Io/Loader.php'); | |
Carica\Io\Loader::register(); | |
use Carica\Io; | |
$mysqlOne = new Io\Deferred\MySQL(new mysqli('127.0.0.1')); | |
$mysqlTwo = new Io\Deferred\MySQL(new mysqli('localhost')); | |
$time = microtime(TRUE); |
OlderNewer