Answers for "php string remove after character"

PHP
3

php remove after character

$s = 'Posted On April 6th By Some Dude';
echo strstr($s, 'By', true); // Posted On April 6th
Posted by: Guest on October-06-2020
3

php remove everything after character

$fullpath = 'folderName/file.ext';
$folder = substr($fullpath, 0, strpos($fullpath, '/'));
echo $folder;
// Output => folderName
Posted by: Guest on March-10-2020
2

php remove everything after symbol

$variable = substr($variable, 0, strpos($variable, "By"));
Posted by: Guest on December-02-2021

Code answers related to "php string remove after character"

Browse Popular Code Answers by Language