How to make a website How to cite a website in APA format How to cite a website in MLA format How to download video from the website PHP array_push break vs continue in PHP How to Install Composer on Windows PHPMyAdmin Login PHP alert Creation of custom php.ini file in CPanel Downgrade php 7.4 to 7.3 Ubuntu Multiple File Upload using Dropzone JS in PHP PHP Dropzone File Upload on Button Click PHP find value in an array PHP Codeigniter 3 Ajax Pagination using Jquery How to Convert array into string in PHP PHP Codeigniter 3 Create Dynamic Tree View using Bootstrap Treeview JS CRUD Operation using PHP & Mongodb PHP Ajax Multiple Image Upload PHP Multidimensional Array Search By Value PHP urlencode() Function Image Gallery CRUD using PHP MySQL How to get selected option value in PHP Array to string conversion in PHP PHP Contact Form PHP string Concatenation PHP Laravel 5.6 - Rest API with Passport PHP compare dates PHP Registration Form PHP ternary operator PHP basename() Function Why do we need Interfaces in PHP file_put_contents() Function in PHP Is_array() Function in PHP How to Use PHP Serialize() and Unserialize() Function PHP Unset() vs Unlink() Function PHP 5 vs PHP 7 PHP Imagearc() Function PHP Imagecharup() Function PHP Imagecolortransparent() Function PHP Imagechar() Function PHP Imagecreate() Function PHP Imagecolorallocate() Function PHP Image createtruecolor( ) Function PHP Imagestring() Function PHP Classes Father of PHP get vs post method in PHP PHP append to array fpassthru() Function in PHP Imagick::borderImage() method in PHP Imagick rotateImage() Function Imagick transposeImage() Function PHP Projects Imagick floodFillPaintImage() Function Imagick::charcoalImage() PHP Imagick adaptiveBlurImage() Function Imagick addImage() Function Imagick addNoiseImage() Function PHP Type Casting and Conversion of an Object to an Object of other class PHP PEAR PHP STR_CONTAINS() Multiple Inheritance in PHP What is a PHP Developer PHP ob_start() Function PHP Beautifier PHP imagepolygon() Function Free PHP Web Hosting PHP Adminer Polymorphism in PHP PHP empty() Function What is PHP-FPM PHP STATIC VARIABLES PHP IDE and Code Editor Software PHP file_get_contents() Function PHP sleep() Function PHP server PHP GMP Functions Detail Reference PHP gmp_abs() Function PHP gmp_add() Function PHP gmp_and()Functions PHP GMP gmp_clrbit() Function PHP GMP gmp_cmp() Function PHP GMP gmp_com() Function PHP gmp_div_q() Function PHP gmp_div_qr() Function PHP gmp_or() function PHP gmp_divexact() Function PHP gmp_export() Function PHP gmp_fact() Function PHP gmp_gcd() Function PHP gmp_import() Function PHP gmp_intval() Function PHP gmp_invert() Function PHP gmp_jacobi() Function PHP gmp_legendre() Function PHP gmp_mod() Function PHP gmp_prob_prime() function PHP gmp_random_bits() function PHP gmp_random_range() function PHP gmp_root() function PHP gmp_rootrem() function PHP gmp_random_seed() function PHP gmp_scan0() function PHP gmp_scan1() function PHP gmp_setbit() function PHP GMP gmp_testbit() Function PHP gmp_random() function PHP gmp_xor() function How to create html table with a while loop in PHP How to Encrypt or Decrypt a String in PHP

PHP Mail

PHP Mail

PHP MySQLi

MySQLi CONNECT MySQLi CREATE DB MySQLi CREATE Table MySQLi INSERT MySQLi UPDATE MySQLi DELETE MySQLi SELECT MySQLi Order by

PHP JSON

PHP JSON Example

PHP OOPs Concepts

OOPs Concepts OOPs Abstract Class OOPs Abstraction OOPs Access Specifiers OOPs Const Keyword OOPs Constructor OOPs Destructor Abstract vs Class vs Interface Encapsulation Final Keyword OOPs Functions OOPs Inheritance OOPs Interface OOPs Overloading OOPs Type Hinting

PHP Topics

Compound Types PHP Float PHP Integer is_null() Function PHP Boolean Special Types Inheritance Task Special Types PHP Encryption Two-way Encryption Heredoc Syntax

PHP MCQ

PHP MCQ

Related Tutorials

MySQL Tutorial WordPress Tutorial CodeIgniter Tutorial YII Tutorial Laravel Tutorial Magento 2 Tutorial

Interview Questions

PHP Interview WordPress Interview Joomla Interview Drupal Interview

PHP string ltrim() function

PHP string ltrim() function is predefined function. It is often used to remove whitespace from both sides of a string or other character from the left side of a string.

Syntax:

ltrim(string,charlist); Parameter Description Required/Optional String Specify the string to check. Required charlist Specify character to remove from the string.
  • "\0" : NULL
  • "\t" : tab
  • "\n" : new line
  • "\x0B" : vertical tab
  • "\r" : carriage return
  • " " : ordinary white space
  • Optional

    Example 1

    $str = " Hello PHP!"; echo "Without ltrim() Function: " . $str; echo "<br>"; echo "With ltrim() function : " . ltrim($str);

    Output:

    Without ltrim() Function: Hello PHP! With ltrim() function : Hello PHP!

    Example 2

    $str = "Hello PHP Javatpoint!"; echo "Without ltrim() Function: " . $str; echo "<br>"; echo "With ltrim() function: " . ltrim($str);

    Output:

    Without ltrim() Function: Hello PHP Javatpoint! With ltrim() function: Hello PHP Javatpoint!

    Example 3

    $str = "\n\n\nHello PHP!"; echo "Without ltrim() funcion: " . $str; echo "<br>"; echo "With ltrim() function: " . ltrim($str);

    Output:

    Without ltrim(): Hello World! With ltrim: Hello World!

    Note: To remove newlines from the left side of a string then we can use (\n):

    Next Topic PHP String