You are here: Re: who is good at regular expressions? « PHP Programming Language « IT news, forums, messages
Re: who is good at regular expressions?

Posted by brendan on 09/07/05 17:32

"Sandman" <mr@sandman.net> wrote in message
news:mr-ECC27F.16230007092005@individual.net...> #!/usr/bin/php
> <?
> $string = "author:Jane Smith institution:university of Cambridge
year:1976";
> $m = preg_split("/\s*(\w+):/", $string, -1,
> PREG_SPLIT_NO_EMPTY|PREG_SPLIT_DELIM_CAPTURE);
> for ($i=0;$i<=count($m)-1;$i+=2){
> $sql_query[] = $m[$i] . " = '" . $m[$i+1] . "'";
> }
> print "select * from database.table where " . join(" and ",
$sql_query);
> ?>
>
> The output:
>
> select * from database.table where author = 'Jane Smith' and institution =
> 'university of Cambridge' and year = '1976'

> Sandman[.net]

Thank you sandman! That works perfectly. Beer waiting at the Eagle for you!
regards,
brendan.

 

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

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