Answers for "php cut string after character"

PHP
1

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 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
0

get substring after character php

<?php
$my_url = 'http://www.example.com/5478631';
echo substr($my_url, strrpos($my_url, '/' )+1)."\n";
?>
  // print: 5478631
Posted by: Guest on January-06-2021

Code answers related to "php cut string after character"

Browse Popular Code Answers by Language