PHP Remove First 2, 3, 4, 5, 10, etc Character From String Example
Hi Dev,
This tutorial shows you how to remove first 2, 3, 4, 5, 10, etc character from string in php?. you can understand a concept of remove first 2, 3, etc character from string in php example. Here you will learn remove first from string php.
There ara three ways to remove first 2, 3, 4, 5, etc Character From string in php. in the first example, we will use to substr() function and the second example is use to ltrim() function this exampale.so Let's see the following example with output.
Example 1: PHP Remove First 2 Character
index.php
<?php
$str = "Hi Nicesnippets.com";
// Remove First 2, 3, 4, etc Character From string
$result = substr($str, 2);
echo $result;
?>
Output:
Nicesnippets.com
Example 2: PHP Remove First 4 Character
index.php
<?php
$str = "Hello World!";
// Remove First 2, 3, 4, etc Character From string
$result = ltrim($str, "Hell");
echo $result;
?>
Output:
o World!
I hope it could help you...
- How To Use Php Conditional Statement Example
- How to Check if String Contains Regex in PHP?
- PHP Array_column() Function Example
- PHP Generate List of Random Numbers Between 0 and 100 Example
- How to User Login with Facebook in PHP?
- How to Explode Every Character into Array Using PHP Example?
- PHP Form Validation Tutorial
- PHP Convert XML to JSON Example