1

dI am using this ajax.php to get livenews auto update. but sometimes it causes high cup usage, sometimes (120%) it is running on a apache. can you please inform me with this issue: the code is:

<?php
$data = file_get_contents('http://domaine.com');
preg_match("/<ul[^>]*id=\"toautoupdate\"[^>]*>(.*?)<\\/ul>/si", $data, $match);
echo $match[1];
?>
  • preg_match can be heavy depending on input length and REG EXP you're using. Is it really the only solution ? What are you trying to do with your preg_match ? – Clément Malet Aug 29 '13 at 09:43
  • preg_match is used to search and get the news from a specific category – Antonio Maarawi Aug 29 '13 at 09:49
  • You want to match `
      ... id="toautoupdate"...
    ` and echo everything in the `
      ` element, right ?
    – Clément Malet Aug 29 '13 at 09:52
  • – Antonio Maarawi Aug 29 '13 at 10:03
  • it is the jquery used in the html of the module – Antonio Maarawi Aug 29 '13 at 10:03
  • any suggestions please? – Antonio Maarawi Aug 30 '13 at 08:42
  • If you've time to learn a DOM parser, the best solution would be this one otherwise : http://stackoverflow.com/questions/3577641/how-do-you-parse-and-process-html-xml-in-php – Clément Malet Aug 30 '13 at 10:32

0 Answers0