#### Other variables

$first = 1;

$day = 24;

Use the normal maths symbols to manipulate numbers. For example:

$two = 1 + 1;

$total = $part1 + $part2;

$result = $one * $two;

$divide = $big / $small;

$net = $gross - $vat;

Variables can also be boolean (true of false). For example,

$correct = true;

$wrong = false;

Next article: Loops and decisions

#### Substring

Use substr to extract part of a string. The format is:

substr(stringname, startpos, length)

where stringname is the name of the full string from which you want to extract something

startpos is an integer that defines the start position for the substring (NOTE: the first character is position 0) length is the length of the substring you want. If you don't give this, PHP assumes you want the rest of the string

Examples:

$stringname = "Substring example";

$first = substr($stringname, 2);

// Returns "bstring example" into $first because startpos of 2 is the b.

$second = substr($stringname, 6, 2);

// Returns "in" into $second

Next article: Loops and decisions

#### Other functions

cos()
Examples
Function Manual

Calculates cosine of a number

html_entities()
Examples
Function Manual

Converts any special characters in a string to their HTML equivalents

ltrim()
Examples
Function Manual

Trims any blanks from the left of a string

mt_rand()
Examples
Function Manual

Generates a random number

nl2br()
Examples
Function Manual

Converts a new line character into a break HTML tag

pow()
Examples
Function Manual

Calculates one number raised to the power of another

round()
Examples
Function Manual

Rounds a number to a number of decimal places

rtrim()
Examples
Function Manual

Trims any blanks from the right of a string

sin()
Examples
Function Manual

Calculates the sine of a number

sqrt()
Examples
Function Manual

Calculates the square root of a number

str_pad()
Examples
Function Manual

Extends the length of a string by adding blanks to it

str_replace()
Examples
Function Manual

Replaces part of one string with other specified characters

str_word_count()
Examples
Function Manual

Counts the number of words in a string

strlen()
Examples
Function Manual

Returns the length of a string

strpos()
Examples
Function Manual

Finds the position of one string within another

strtolower()
Examples
Function Manual

Converts a string to all lowercase

strtoupper()
Examples
Function Manual

Converts a string to all uppercase

tan()
Examples
Function Manual

Calculates the tangent of a number

Next article: Loops and decisions