All pastes #18359 Raw Edit

Skudd

public text v1 · immutable
#18359 ·published 2005-07-23 23:03 UTC
rendered paste body
<?php
	function MakeURL($str) {
		$words = str_replace("\r\n", " \r\n", $str);
		$words = str_replace("\n", " \n", $words);
		$words = explode(" ", $words);
		
		foreach($words as $word) {
			$_word = trim($word);
			
			$prefix = substr($_word, 0, strpos($_word, '//') + 2);
			if($prefix == 'http://' || $prefix == 'ftp://') {
				$out .= "<a href=\"$_word\">$word</a> ";
			} else {
				$out .= "$word ";
			}
		}
		
		return $out;
	}
?>