Pass true as the third parameter.
On the page that you indicated :
string strstr (string $haystack , mixed $needle [, bool $before_needle = false ])
before_needle : if TRUE, strstr () returns the portion of the haystack before the first occurrence of the needle (excluding the needle).
Note. This option was added only in PHP 5.3. If for some reason you have an old version, a combination of substr()
and strpos()
should help:
$newstr = substr( $var, 0, strpos( $var, '(' ) );
kapa source share