Belgin Fish Belgin Fish - 1 year ago 88
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"


Answer Source
$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.

Recommended from our users: Dynamic Network Monitoring from WhatsUp Gold from IPSwitch. Free Download