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

Posted by jamen on 12/18/05 02:32

Unknown wrote:

> 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.

Look into regular expressions

$str = "DVD Region: 2 - Title: Star Wars - Price: £14.99 - Brought:
10/10/05";

if(preg_match("#Price: (\\S+)#", $str, $m)){
echo "price: " . $m[1];
}

preg_match_all can find all matches in a string

 

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

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