What is the PHP function used to extract a portion of a string?
To extract a portion of a string in PHP, you can use the `substr()` function. This function takes three parameters: the string you want to extract from, the starting position of the extraction, and optionally the length of the extracted substring. Example:
$string = "Hello, World!";
$extracted = substr($string, 7, 5); // Extracts "World" starting from position 7
echo $extracted; // Output: World
Related Questions
- How can one ensure that the content fetched using file_get_contents is always up-to-date and not cached?
- What are some best practices for integrating Facebook SDK into a website, especially for a video platform with database interactions?
- What are the potential benefits and drawbacks of using output buffering in PHP to manipulate generated content?