Difference between revisions of "$left"

From Scriptwiki
Jump to: navigation, search
m
m
Line 10: Line 10:
 
== Examples ==
 
== Examples ==
  
=== $left and other [[Identifiers|idenfiers]] ===
+
=== $left and other [[Identifiers|identifiers]] ===
  
 
What about if you don't know users gender, is it going to be she or he, boyfriend.jpg or girlfriend.jpg
 
What about if you don't know users gender, is it going to be she or he, boyfriend.jpg or girlfriend.jpg

Revision as of 08:09, 25 August 2005

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