replace anything in brackets in a string using preg_replace regex php

Lets say we have a string like this

hi there im a string (not really a string).

and we want to remove this bit

(not really a string)

We can do this using the following regex (preg_replace)

$string = "hi there im a string (not really a string)."; 
echo preg_replace("/\([^)]+\)/","",$string); // 'hi there im a string.'

Other Items in php
Page Views

This page has been viewed 264 times.

Search Code
Search Code by entering your search text above.

This is my test area for webdev. I keep a collection of code snippits here, mostly for my reference. Also if i find a good site, i usually add it here.


Random Quote
therock Somewhere along this crazy road I learned (often times the hard way) the most important things I can do is be authentic, trust my gut, be the hardest worker in the room, celebrate the mistakes, be a grateful man and always remember that it's nice to be important, but it's more important to be nice.
The Rock