Monthly Archiv: April, 2009

Text URL to HTML

<?php
function to_link($string){
return preg_replace("~(http|https|ftp|ftps)://(.*?)(\s|\n|[,.?!](\s|\n)|$)~", ‘<a href="$1://$2">$1://$2</a>$3’,$string);
}

$html = ‘This line of text has three

Database Search

<?php
include ‘incl/db.php’; // Include the database
// Set the page, use one if the get page is not a number or is negative
if(!isset($_GET[‘page’]) || !ctype_digit($_GET[‘page’]))
$page = 1

Return Between

<?php
function return_between($string, $start, $stop){
$st = $string;
$list = array();
for($i=0;$i<strlen($string);$i++){
$temp = strpos($st, $start);
$str = substr($st, $temp+1);
$spl

Alexa/Google Page Rank

<?php
function page_rank($page, $type = ‘alexa’){
switch($type){
case ‘alexa’:
$url = ‘http://alexa.com/siteinfo/’;
$handle = fopen($url.$page, ‘r’);
break;
case ‘google’:
$url

Define a variable

<?php
$variable = ‘Hello Kitty!’;
if($variable == ‘Kitty’){
echo ‘Goodbye Kitty.’;
}else{
// Note the extra space before "How"
// Remove it and then see what happens…
echo $vari

Powered by Gewgley