-->

  • strpos() - strrpos() Search For a Text Within a String in php



    strpos() - strrpos- Search For a Text Within a String
    strpos() - strrpos- Search For a Text Within a String




    In this blog, we will teach you about PHP ucwords() function. Basically we have also teach about basics of PHP 7 . so, you will go to our previous Blog for learn about PHP and for your kind information we also have a YouTube channel, which we continuously uploaded videos of HTML, CSS, PHP and Tech Videos. so please subscribe to our YouTube channel.




    YouTube Channel :-  Kumar Atul Jaiswal



    The strpos()  |  strrpos - Search For a Text Within a String in PHP

    This function helps us to find the position of the first occurrence of a string in another string. This returns an integer value of the position of the first occurrence of the string. This function is case-sensitive, which means that it treats upper-case and lower-case characters differently. strpos() - strrpos- Search For a Text Within a String

    or


    The PHP strpos() function searches for a specific text within a string. If a match is found, the function returns the character position of the first match. If no match is found, it will return FALSE.




    Syntax

    strpos (string, find, start)

    strrpos (string, find, start)


    Note :-  The first character position in a string is 0 (not 1).



    Example 

    <!DOCTYPE html>
    <html>
    <head>

    <title> PHP  strpos () Function </title>

    </head>
    <body>

    <h1> </h1>


    <?php

    echo strpos ("Hello world", "world");

    echo "<br>";

    echo strpos ("Kumar Atul Jaiswal", "Jaiswal");

    echo "<br>";

    $mystring =   strpos ("I love Hacking Truth, I love Hacking Truth too",  "love");

    echo  $mystring );

    echo "<br>";

    $yourstring =   strrpos ("I love Hacking Truth, I love Hacking Truth too",  "love");

    echo  $yourstring );



    ?>


    </body>
    </html>






    6
    11

    2
    24






    Note: The strpos() function is case-sensitive.

    Note: This function is binary-safe.

    strpos() -The strpos() function finds the position of the first occurrence of a string inside another string. (case-sensitive)

    strrpos() - Finds the position of the last occurrence of a string inside another string (case-insensitive)






    NOTE :- Video on This Topic :- Soon





    Have a Nice Stay Here : - )






  • 0 comments:

    Post a Comment

    For Any Tech Updates, Hacking News, Internet, Computer, Technology and related to IT Field Articles Follow Our Blog.