About 10,700,000 results
Open links in new tab
  1. PHP strpos() Function: locating a substring within a string - PHP

    The PHP strpos() function returns the index of the first occurrence of a substring within a string. Here’s the syntax of the strpos() function: The strpos() function has the following parameters: The $needle is a string value to search for. The $offset is an integer that represents the index at which the strpos() function starts the search.

  2. How to check if a String Contains a Substring in PHP

    Aug 8, 2024 · In this article, we are going to check if the given string contains a substring by using the PHP strpos () function. Syntax: Parameters: sub_string : The substring searched in the original input string. Return type: Boolean value. False, If substring not found. Example: Output: Example 2: Output:

  3. PHP substr() Function - W3Schools

    Return "world" from the string: The substr () function returns a part of a string. Required. Specifies the string to return a part of. Required. Specifies where to start in the string. Optional. Specifies the length of the returned string. Default is to the end of the string.

  4. PHP to check substring in a string - GeeksforGeeks

    Nov 30, 2021 · How to check if a String Contains a Substring in PHP ? A string is a collection of given characters and a substring is a string present in a given string. In this article, we are going to check if the given string contains a substring by using the PHP strpos() function.

  5. How to Extract Substring from a String in PHP? - GeeksforGeeks

    Jul 22, 2024 · The substr() function is used to extract a substring from a string in PHP. It takes three arguments: the input string, the starting position (zero-based index), and optionally the length of the substring to extract.

  6. PHP: str_contains - Manual

    Performs a case-sensitive check indicating if needle is contained in haystack. The substring to search for in the haystack. Returns true if needle is in haystack, false otherwise. echo "Checking the existence of the empty string will always return true"; The above example will output: echo "The string 'lazy' was found in the string\n";

  7. Extract a substring between two characters in a string PHP

    Feb 15, 2013 · Is there a PHP function that can extract a phrase between 2 different characters in a string? Something like substr(); Example: Thus $id would be 256. Any help would be appreciated :) You can do it in two parts: you firstly get string from $first and then parse the result till the $second character.

  8. PHP substr(): How to Extract a Substring from a String - PHP

    Use the PHP substr() function to extract a substring from a string. Use the negative offset to extract a substring from the end of the string. The last character in the input string has an index of -1 .

  9. Check if a substring occurs within a string in PHP

    Dec 28, 2022 · This article demonstrates how to check if a substring occurs within a string in PHP. 1. Using strpos() function. The strpos () function returns the index of the first occurrence of a substring in a string, and false if the substring is not found.

  10. PHP Program to check if a sub string is present in the string

    Apr 22, 2022 · PHP Programming: Check whether a given substring is present in the given string. Sample Program to Search a Substring in a String with Output.

  11. Some results have been removed