Cut string after specified character in php

后端 未结 2 663
独厮守ぢ
独厮守ぢ 2021-01-27 06:52

I try to cut a text after the occurence of a specified character, in this case:

The text example is:

...text?“ Text,
         


        
2条回答
  •  無奈伤痛
    2021-01-27 06:54

    The strpos() command requires 3 parameters

    1) The Variable

    2) The start column and

    3) the numbers of characters

    If you just use substr($title,$pos2) you get the text from the pos2 column to the end of the string.

    RESULT

    before“
    

    Also test for not equal false as strpos returns FALSE if it does not find the character you are searching for

    After all the discussion below I ran it on my local Apache/PHP

    
    
    
    
        <?php echo $header_title;?>
    
    
    
        
    Ello Wurld

    Produces:

提交回复
热议问题