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

Large Data One Query

<?php
// include the database
include ‘db.php’;
$query = ‘INSERT INTO `table_name` (`ownerID`, `favorites`) VALUES ‘;
// This foreach we will pretend that we passed an array of
// checkboxs,

Check Prime Numbers

<?php
function is_prime($num){
for($i=$num;$i > 0;$i–){
$v = $num / $i;
if(!is_float($v)){
if($v != $num && $v != 1)
return FALSE;
}
}
return TRUE;
}

for($i = 1;$i<=100;$

Watermark An Image

<?php
function watermark($file, $watermark, $pos = null, $x = 0, $y = 0){
$details = getimagesize($file);
$wDetails = getimagesize($watermark);
if(!is_null($pos)){
switch($pos){
case TOP

Get Inserted ID Number

<?php
// Insert into database
mysql_query("INSERT INTO my_table (`column1`, `column2`) VALUES (‘one’, ‘two’)");
// Next Get what the auto incremented number was that was inserted
$id = mysql_inser

HTML/XHTML and XML Writer

Package:
Summary:
Generate HTML and XML programatically
Groups:
Author:
Description:
This class can be used to Generate HTML and XML documents programatically.

It can add arbitrary text and tags to a document. The tags may have optional attributes.

The class can also provide support to generate common HTML for form inputs with data retrieve from submitted inputs or database queries, listing pagination links, list menus, etc..

The class generates XML or XHTML compliant HTML.


simple BBCode

Package:
Summary:
Convert BBCode formatted text to HTML
Groups:
Author:
Description:
This class can be used convert BBCode formatted text to HTML.

It can find and replace BBcode tags and replace it by HTML.

The class provides support to some predefined tags but also allows adding new custom tags that can be either single tags or open and close tags that delimit sections.


Powered by Gewgley