0

I have this string: mr (3_22)

I want php to output that string to: (3_22)

How can i do that with PHP? I need a sample code please

3
  • php.net/preg_match_all should help. Commented Mar 17, 2019 at 16:09
  • That's not a useful question title; being descriptive is important for future users who want to find similar topics. Commented Mar 17, 2019 at 16:27
  • 1
    Possible duplicate of PHP split alternative? Commented Mar 17, 2019 at 17:04

1 Answer 1

1

Try the following code:

$str ='mr (3_22) mrs (1_12) miss (2_4)';
$re ='';
if(preg_match_all('/(\([^\)]+\))/i', $str, $mt)){
  $re = implode('', $mt[0]);
}
echo $re; // (3_22)(1_12)(2_4)
Sign up to request clarification or add additional context in comments.

Comments

Your Answer

By clicking “Post Your Answer”, you agree to our terms of service and acknowledge you have read our privacy policy.

Start asking to get answers

Find the answer to your question by asking.

Ask question

Explore related questions

See similar questions with these tags.