How to remove the first character of string in PHP?

admin_img Posted By Bajarangi soft , Posted On 31-12-2020

In PHP to remove characters from beginning we can use ltrim but in that we have to define what we want to remove from a string i.e. removing characters are to be known.

remove first character if string in php

Remove the very first character of a given string in PHP
Examples:

Input : software info tech
Output : software info tech

Input :, Hello infotech!
Output : Hello infotech!
Explanation:
In PHP to remove characters from beginning we can use ltrim but in that we have to define what we want to remove from a string i.e. removing characters are to be known.
Example

<?php 
    $str = "info tech solutions"; 
  
    // Or we can write ltrim($str, $str[0]); 
    $str = ltrim($str, 'i'); 
  
    echo $str; 
?> 

Related Post