$left

From Scriptwiki
Jump to: navigation, search

Returns the N left characters of text.

$left(text,N)

$left(girlfriend.jpg, 10) returns girlfriend, the first ten characters from the beginning.

By giving N a negative value you get all except N characters. $left(girlfriend.jpg, -4) returns the same value.

Examples

$left and other identifiers

What about if you don't know users gender, is it going to be she or he, boyfriend.jpg or girlfriend.jpg We can use

$left(girlfriend, $pos(girlfriend.jpg, ., 1))

to get the same result.

$left and aliases

var %c = 1, %str = cawabunga
while (%c <= $len(%str)) {
  echo -a $left(%str, %c)
  inc %c
}

Prints:

c
ca
caw
cawa
cawab
cawabu
cawabun
cawabung
cawabunga

Also See