You are here: Re: String Editing Question « PHP Language « IT news, forums, messages
Re: String Editing Question

Posted by meltedown on 12/20/05 06:32

Unknown wrote:
> Hi,
>
> I wonder if anyone can help with a basic question I have with editing a
> string.
>
> I am importing some code from a text file and it has lines like the
> following...
>
> DVD Region: 2 - Title: Star Wars - Price: £14.99 - Brought: 10/10/05
> DVD Region: 1 - Title: Empire Strikes - Price: $9.50 - Brought: 05/05/02
>
> All I am purely interested in is pulling the price out of the string
> that each line is held in. So for example I would like $strPRICE to
> equal £14.99 in the first instance and ignore the contents of the string
> on either side.
>
> Can anyone advise on the command and syntax I need to use?
>
> Many thanks.
>
$text="DVD Region: 2 - Title: Star Wars - Price: L14.99 - Brought:
10/10/05";

preg_match("|- Price:(.*) -|",$text,$matches);
$matches will be:
[Array
(
[0] => - Price: L14.99 -
[1] => L14.99
)
]

 

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

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