All pastes #772273 Raw Edit

Stuff

public text v1 · immutable
·published 2007-11-13 18:10 UTC
rendered paste body
function clean($string) {
	while(strstr($string, "  ")) { 
		$string = str_replace("  ", " ", $string);
	} 
	return $string;
}

function php($function) {
	$html = file_get_contents("http://php.net/$function");
	$html = str_replace("\n", "", $html);
	preg_match("/<div class=\"refnamediv\">(.*?)<\/p><p>(.*?)<\/p><\/div><h2>Description<\/h2>(.*?)<p>(.*?)<\/p><h2>/", $html, $matches);
	if (!$matches[1]) {
		return FALSE;
	} else {
		for ($x = 1; $x < 5; $x++) {
			$return[($x-1)] = clean(str_replace("—", "--", html_entity_decode(strip_tags(trim($matches[$x])))));
		}
		$return[4] = "Url: http://php.net/".str_replace(" ", "_", $function);
		return $return;
	}
}