Actually I want to remove everything from `By`, my answer should be Posted On March 6th. I am using the below code. it is working. but the problem is some times if there is no `By` in the given string then echo value is not showing at all.

```
$s = 'Posted On March 6th By Cristiano';

$variable = substr($s, 0, strpos($s, "By"));
echo $variable;

```

or

```
$variable = strstr($s, 'By', true);
echo $variable;

```