You are here: PREG search for multiple values in one pass? « PHP Programming Language « IT news, forums, messages
PREG search for multiple values in one pass?

Posted by terence.parker on 08/19/06 01:46

I am trying to do a search through some data, more specifically HTML,
to extract data from it. So for example I may have:

<b>Title:</b> <em>This is a title</em>
<b>Name:</b> <em>Fred</em>

I wish to grab the data "This is a title" and "Fred" against their
corresponding headings in an array (e.g. $array[title] = "This is a
title") .... but the key doesn't matter, that need not come from the
regexp but I can do manually.

The question is - how do I do this in one pass? Do I just use use
nested OR's in my regexp? The problem with this though, is once a match
is made, how does PHP then tell me what it corresponds to if it's an
OR? (it just returns the match surely?)

Actually i'm not even too sure how to go about doing this... do I need
backreferencing etc...? I've read the php.net pages but couldn't
entirely make sense of the various preg functions.

Thanks a bunch!

Terence

 

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

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