Answers for "php remove part string 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

Code answers related to "php remove part string after character"

Browse Popular Code Answers by Language