Pass a negative value as the length
argument (the 3rd argument) to substr()
, like:
$result = substr($string, 3, -3);
So this:
<?php
$string = "Sean Bright";
$string = substr($string, 3, -3);
echo $string;
?>
Outputs:
n Bri
More Related Contents:
- How to get first x chars from a string, without cutting off the last word?
- PHP: How to sort the characters in a string?
- How do I remove the last comma from a string using PHP?
- Remove first 4 characters of a string with PHP
- I want to make my password to contain lowercase, uppercase, 8 characters and a character
- PHP, get file name without file extension
- URL Friendly Username in PHP?
- PHP: Split string [duplicate]
- PHP equivalent of .NET/Java’s toString()
- How to mimic Stack Overflow Auto-Link Behavior
- how to replace special characters with the ones they’re based on in PHP?
- How can I truncate a string to the first 20 words in PHP?
- Remove control characters from PHP string
- PHP function to delete all between certain character(s) in string
- How to split a long string without breaking words?
- PHP String to Float
- How do you pull first 100 characters of a string in PHP
- Get the first letter of each word in a string
- PHP variable interpolation vs concatenation [duplicate]
- Extract a substring between two characters in a string PHP
- Separate space-delimited words in a string [duplicate]
- php substr() function with utf-8 leaves � marks at the end
- Return the portion of a string before the first occurrence of a character in PHP [duplicate]
- How to check if letter is upper or lower in PHP?
- PHP get values from SimpleXMLElement array
- How to implode array with key and value without foreach in PHP
- How can I get the last 7 characters of a PHP string?
- Convert a String to Variable
- Format 32-character string with hyphens to become UUID
- finding common prefix of array of strings