|
Posted by robert on 04/27/06 00:03
"MattMika" <mattmika@hotmail.com> wrote in message
news:u8iv42ptb972mpamij2jni9girmhs5ofpg@4ax.com...
| On Wed, 26 Apr 2006 12:53:26 -0500, "robert"
| <ab@no.spam-alama-ding-dong> wrote:
|
| >the key is the length of characters after the starting point...you're
| >telling it to grab the next 43 characters that follow position 36. have a
| >look:
|
| Ahhh! I knew that, but wasnt paying ATTN. Here's what I came up with:
|
| $string = "United Parcel Service (1 x 0.55lbs) (Ground):";
| $start = strrpos($string, '(');
| $end = strrpos($string, ')');
| $span = ($end - $start);
| $editstring = substr($string, ($start + 1), ($span - 1));
| echo "<i>Edited String : </i>" . $editstring;
|
| now it returns
|
| Ground
|
| Just like I wanted. Is there a more elegant way to do this?
|
| Thanks robert,
no problem...try this:
preg_match_all('/(\([^)]*?\))/', $string, $matches);
echo '<pre>' . print_r($matches[0][count($matches) - 1], true) . '</pre>';
Navigation:
[Reply to this message]
|