php remove after character
snippet in php

php remove everything after character

user8206

$fullpath = 'folderName/file.ext';
$folder = substr($fullpath, 0, strpos($fullpath, '/'));
echo $folder;
// Output => folderName

php remove after character

user3872

$s = 'Posted On April 6th By Some Dude';
echo strstr($s, 'By', true); // Posted On April 6th