You are here: Re: String Manipulation Question « All PHP « IT news, forums, messages
Re: String Manipulation Question

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]


Удаленная работа для программистов  •  Как заработать на Google AdSense  •  England, UK  •  статьи на английском  •  PHP MySQL CMS Apache Oscommerce  •  Online Business Knowledge Base  •  DVD MP3 AVI MP4 players codecs conversion help
Home  •  Search  •  Site Map  •  Set as Homepage  •  Add to Favourites

Copyright © 2005-2006 Powered by Custom PHP Programming

Сайт изготовлен в Студии Валентина Петручека
изготовление и поддержка веб-сайтов, разработка программного обеспечения, поисковая оптимизация