etrader Posted March 31, 2011 Share Posted March 31, 2011 I have searched a lot but no information about this aspect. I wonder how much heavy is the process of getting parts of a webpage by preg_match? But my question is that which of these options are in favor of lighter CPU process: 1. getting each item between specified tags by a preg_match or 2. First getting the content between <body>, then processing by php tools such as preg_match (again), explode, etc. Thanks for considering this unusual question Quote Link to comment https://forums.phpfreaks.com/topic/232279-question-about-cpu-usage-by-preg_match/ Share on other sites More sharing options...
bh Posted March 31, 2011 Share Posted March 31, 2011 Hi, you should query in the minimal content u can. If your parts in anywhere in the body get the entiry body and run the search loop in it. If those in a div get that div... Anyway regexp is not a fast method. You can use str pos in a loop, with the handy offset paramterer. Quote Link to comment https://forums.phpfreaks.com/topic/232279-question-about-cpu-usage-by-preg_match/#findComment-1194909 Share on other sites More sharing options...
etrader Posted March 31, 2011 Author Share Posted March 31, 2011 Thanks for your reply. You mean it is better to query all <div> by individual preg_match as they will work simultaneously? Right? You mean that getting the body into a string and then analyzing is a step by step process which takes time? OK? Quote Link to comment https://forums.phpfreaks.com/topic/232279-question-about-cpu-usage-by-preg_match/#findComment-1194955 Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.