Still celebrating National IT Professionals Day with 3 months of free Premium Membership. Use Code ITDAY17


Extract data between brakets

Posted on 2008-06-12
Medium Priority
Last Modified: 2013-12-13
I want to remove the data between brackets in php like:

$string = 10K White Gold(+100);

$result = +100
Question by:dougbnv
Welcome to Experts Exchange

Add your voice to the tech community where 5M+ people just like you are talking about what matters.

  • Help others & share knowledge
  • Earn cash & points
  • Learn & ask questions
LVL 29

Accepted Solution

rdivilbiss earned 500 total points
ID: 21771063

$string = "10K White Gold(+100)";
$first = strpos($string,'(');
$last = strrpos($string,')');
$len = $last-$first-1;
$result = substr($string,$first+1,$len);
echo $result.'<br>';
$result = substr($string,strpos($string,'(')+1,strrpos($string,')')-strpos($string,'(')-1);
echo $result;

Open in new window


Expert Comment

ID: 21771502
$string = '10K White Gold(+100)';

$result = substr($string, strpos($string, "(")+1, strpos($string, ")") - (strpos($string, "(")+1));

echo $result;

Author Closing Comment

ID: 31466595
Perfect thanks!

Featured Post

What does it mean to be "Always On"?

Is your cloud always on? With an Always On cloud you won't have to worry about downtime for maintenance or software application code updates, ensuring that your bottom line isn't affected.

Question has a verified solution.

If you are experiencing a similar issue, please ask a related question

I imagine that there are some, like me, who require a way of getting currency exchange rates for implementation in web project from time to time, so I thought I would share a solution that I have developed for this purpose. It turns out that Yaho…
Part of the Global Positioning System A geocode ( is the major subset of a GPS coordinate (, the other parts being the altitude and t…
This tutorial will teach you the core code needed to finalize the addition of a watermark to your image. The viewer will use a small PHP class to learn and create a watermark.
The viewer will learn how to create a basic form using some HTML5 and PHP for later processing. Set up your basic HTML file. Open your form tag and set the method and action attributes.: (CODE) Set up your first few inputs one for the name and …

705 members asked questions and received personalized solutions in the past 7 days.

Join the community of 500,000 technology professionals and ask your questions.

Join & Ask a Question