<?php $string = "The quick (brown fox jumps) over (the lazy dog)"; //First preg search all string in () preg_match_all('/\(.(.*?).\)/', $string, $match); foreach ($match[0] as $key => $value) { $result = preg_replace('/\s+/', '', $value); if(isset($new_string)){ $new_string = str_replace($value, $result, $new_string); }else{ $new_string = str_replace($value, $result, $string); } } echo $new_string; ?>
You have javascript disabled. You will not be able to edit any code.