You can use preg_match
$str = 'Abc/hello@gmail.com/1267890(A-29)';
if( preg_match('/\(([^)]+)\)/', $string, $match ) ) echo $match[1]."
";
Outputs
A-29
You can check it out here
http://sandbox.onlinephpfunctions.com/code/5b6aa0bf9725b62b87b94edbccc2df1d73450ee4
Basically Regular expression says:
- start match, matches
\(
Open Paren literal
- capture group
( .. )
- match everything except
[^)]+
Close Paren )
- end match, matches
\)
Close Paren literal
Oh and if you really have your heart set on substr
here you go:
$str = 'Abc/hello@gmail.com/1267890(A-29)';
$start = strpos( $str,'(') +1;
$end = strpos( $str,')');
$len = ($end-$start);
echo substr($str, $start, $len );
Ouputs
A-29
And you can test this here
http://sandbox.onlinephpfunctions.com/code/88723be11fc82d88316d32a522030b149a4788aa
If it was me, I would benchmark both methods, and see which is faster.