Skip to content

Instantly share code, notes, and snippets.

View ThomasWeinert's full-sized avatar
💻
programming

Thomas Weinert ThomasWeinert

💻
programming
View GitHub Profile
@ThomasWeinert
ThomasWeinert / gist:4500763
Last active December 10, 2015 22:18 — forked from tliff/gist:4500652
<?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;
@ThomasWeinert
ThomasWeinert / tailrecursion.php
Created November 28, 2012 18:02 — forked from beberlei/tailrecursion.php
PHP Tail Recursion
<?php
class TailRecursion {
private $_function = NULL;
private $_arguments = array();
private $_recursing = FALSE;
private $_recursion = NULL;
public function __construct(Callable $function) {