Linux and UNIX Man Pages

Linux & Unix Commands - Search Man Pages

ltrim(3) [php man page]

LTRIM(3)								 1								  LTRIM(3)

ltrim - Strip whitespace (or other characters) from the beginning of a string

SYNOPSIS
string ltrim (string $str, [string $character_mask]) DESCRIPTION
Strip whitespace (or other characters) from the beginning of a string. PARAMETERS
o $str - The input string. o $character_mask - You can also specify the characters you want to strip, by means of the $character_mask parameter. Simply list all characters that you want to be stripped. With .. you can specify a range of characters. RETURN VALUES
This function returns a string with whitespace stripped from the beginning of $str. Without the second parameter, ltrim(3) will strip these characters: o " " (ASCII 32 ( 0x20)), an ordinary space. o " " (ASCII 9 ( 0x09)), a tab. o " " (ASCII 10 ( 0x0A)), a new line (line feed). o " " (ASCII 13 ( 0x0D)), a carriage return. o "" (ASCII 0 ( 0x00)), the NUL-byte. o "x0B" (ASCII 11 ( 0x0B)), a vertical tab. EXAMPLES
Example #1 Usage example of ltrim(3) <?php $text = " These are a few words :) ... "; $binary = "x09Example stringx0A"; $hello = "Hello World"; var_dump($text, $binary, $hello); print " "; $trimmed = ltrim($text); var_dump($trimmed); $trimmed = ltrim($text, " ."); var_dump($trimmed); $trimmed = ltrim($hello, "Hdle"); var_dump($trimmed); // trim the ASCII control characters at the beginning of $binary // (from 0 to 31 inclusive) $clean = ltrim($binary, "x00..x1F"); var_dump($clean); ?> The above example will output: string(32) " These are a few words :) ... " string(16) " Example string " string(11) "Hello World" string(30) "These are a few words :) ... " string(30) "These are a few words :) ... " string(7) "o World" string(15) "Example string " SEE ALSO
trim(3), rtrim(3). PHP Documentation Group LTRIM(3)

Check Out this Related Man Page

ITERATOR(3)								 1							       ITERATOR(3)

The Iterator interface

INTRODUCTION
Interface for external iterators or objects that can be iterated themselves internally. INTERFACE SYNOPSIS
Iterator Iteratorextends Traversable Methods o abstractpublic mixed Iterator::current (void ) o abstractpublic scalar Iterator::key (void ) o abstractpublic void Iterator::next (void ) o abstractpublic void Iterator::rewind (void ) o abstractpublic boolean Iterator::valid (void ) PREDEFINED ITERATORS
PHP already provides a number of iterators for many day to day tasks. See SPL iterators for a list. EXAMPLES
Example #1 Basic usage This example demonstrates in which order methods are called when using foreach with an iterator. <?php class myIterator implements Iterator { private $position = 0; private $array = array( "firstelement", "secondelement", "lastelement", ); public function __construct() { $this->position = 0; } function rewind() { var_dump(__METHOD__); $this->position = 0; } function current() { var_dump(__METHOD__); return $this->array[$this->position]; } function key() { var_dump(__METHOD__); return $this->position; } function next() { var_dump(__METHOD__); ++$this->position; } function valid() { var_dump(__METHOD__); return isset($this->array[$this->position]); } } $it = new myIterator; foreach($it as $key => $value) { var_dump($key, $value); echo " "; } ?> The above example will output something similar to: string(18) "myIterator::rewind" string(17) "myIterator::valid" string(19) "myIterator::current" string(15) "myIterator::key" int(0) string(12) "firstelement" string(16) "myIterator::next" string(17) "myIterator::valid" string(19) "myIterator::current" string(15) "myIterator::key" int(1) string(13) "secondelement" string(16) "myIterator::next" string(17) "myIterator::valid" string(19) "myIterator::current" string(15) "myIterator::key" int(2) string(11) "lastelement" string(16) "myIterator::next" string(17) "myIterator::valid" PHP Documentation Group ITERATOR(3)
Man Page