I build my application using Zend-framework and Jquery, in the application there is Articles and Comments, users can put links in the comments, My question is how I can "Scan" posted comments and get posted Links to suggest them to other users? do I need some PHP-regex or a Jquery plugin? My Comments and Articles are stored in the DB, (I think SO use same system). Thanks.
Asked
Active
Viewed 37 times
1 Answers
0
Use PHP's DOMDocument
and it's getElementsByTagName
method.
Don't use regular expressions since they aren't a good fit for parsing HTML.

Bart
- 17,070
- 5
- 61
- 80
-
There too few details in the original post to support this. If the comments are stored in a database, it wouldn't make much sense to generate a document for DOMDocument to consume when a query will work just as well. – George Cummins Jun 21 '13 at 21:23
-
http://stackoverflow.com/questions/1732348/regex-match-open-tags-except-xhtml-self-contained-tags/1732454#1732454 – musicnothing Jun 21 '13 at 21:24
-
1@GeorgeCummins What I get from the question is that he'd like to extract the links and (what I assume) store them somewhere else for faster indexing so he can easily suggest them to other users. I don't really see how a query would be beneficial in this case. – Bart Jun 21 '13 at 21:41