The function of substr() and strpos() is used to remove part of the string behind a certain letter.

strpos() function: This function is used to determine the initial occurrence of a string within a series. The function returns the total value of the position for the first appearance of the thread. The function handles the upper and lower case letters differently.


Syntax:

strpos( original_string, search_string, start_pos )


substr() function: The substr() function constructed within PHP is used to extract a specific part of a series.

Syntax:

substr( string_name, start_position, string_length_to_cut )


#example.php

    <?php
   // Declare a variable and initialize it 
    $variable = "Rathorji Thank For Great Tutorial";

     // Use substr() and strpos() function to remove 
    // portion of string after certain character 
    $variable = substr($variable, 0, strpos($variable, "For"));

    // Display value of variable 
    echo $variable;
    ?> 


output:

Rathorji Thank For Great Tutorial
Rathorji Thank