Belgin Fish Belgin Fish - 22 days ago 4
PHP Question

Remove portion of a string after a certain character

I'm just wondering how I could remove everything after a certain substring in PHP


Posted On April 6th By Some Dude

I'd like to have it so that it removes all the text including, and after, the sub string "By"


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

In plain english: Give me the part of the string starting at the beginning and ending at the position where you first encounter the deliminator.