I am getting a response $str by using cURL. $str is in html, comprising of always total 327 lines. I want to fetch date from exactly 127th line, which originally is
<b>Last Updated On:</b>17-Dec-2011 11:33:41 UTC<br><br>
To try to reduce the memory used by $str, immidiatly after cURl, i do
$str = strip_tags($str);
Then, to fetch the complete line,
preg_match("/^Last Updated On……………………./m", $str, $line);
$lastupdate = $line[0];
Then, to remove the extra text,
$lastupdate = str_replace("Last Updated On:", "", $lastupdate);
Now I think that this preg_match statement is not the most efficient one. It is using too many dots and there must be something like
LookFor = Last Updated On:
If you see LookFor, get next 25 characters.
Am I using correct preg_match syntex? At the moment it is working, and giving me desired result, but I dont know how it is working.
Please suggest me the correct/efficient equivalent of this preg match line.
Also, how can I tell PHP to jump to directly 127th line, instead of going through all the first 126 lines. All lines having [CR][LF] endings.
P.S.
- There will be only next 25 characters I need.
- The line I need will always be 127th
- I am using the retrieved date just as a string of text; no calculations, only to store in a .csv file. But would really be happy if instead of text, I could get it in proper date format. Right now it is just a string of text.
Try this :
Output :