Main Menu
Latest Articles
Login Form
| Using Function To parse Preg_replace |
|
|
|
| Written by Administrator | ||||
| Saturday, 27 October 2007 | ||||
|
It is Possible to use a function to format the output of a preg_replace. This can be accomplished using backreferences.
the following example assumes that freelance-window.com sells books and pays commissions to affilates who send customers to them. PHP Code:
//original link or links nested in other content
If i did everything right the above code should output: Code:
it seems trivial at first but its very useful when taking information off other websites, parsing that information and redisplaying it on your own. You may also parse info for the purpose of storing it in the database. The whole point of this is 1) make the script neater 2) function parseid allows for much more complex operations using the information found in a match. this function could also be part of a class...example PHP Code:
class scraper{$freelance_window->parseid($backreferenceid);
Add to favourite articles (117) | Place this article on your website | Views: 473
Only registered users can write comments. |
||||
| Last Updated ( Thursday, 22 November 2007 ) | ||||


