PHP:String Functions

From Progzoo
Jump to: navigation, search

The methods and properties of the String type include:

$s="Andrew was here"
ExampleValueComment
$s." once""Andrew was here once"The strings are concatenated using .
$s == "another"falseTests for equality - use ne for not equals
strpos($s,"was")7Returns -1 if the substring is not there.
strlen($s)15The number of characters
explode(" ",$s)("Andrew","was","here")Returns an array of String.
substr($s,2,7)"drew"Characters from position 2 to just before 7
strtoupper($s)"ANDREW WAS HERE"Also strtolower()