Jump to content

Small preg_match help needed


aditya_sfs

Recommended Posts

Hello guys,

I am a PHP newbie and need a bit of help in developing a tool.

I need to count the number of backlinks a site has in MSN. For this i search msn for "link:www.domain.com". I use the following code to do this

<?php
$lines = file('http://search.live.com/results.aspx?q=link%3Adomain.com');
echo "Line #73 : " . htmlspecialchars($lines[73]) . "<br />\n";
?>

Now line 73 is a big complicated HTML string which can be accessed with $lines[73]. Somewhere in the sting, a small part of it is -

<h1>link:domain.com</h1><h5>Page 1 of 26,915 results</h5>

Now i want to get that number 26,915 out in another variable and also removing out that comma so that i could do arithmetic operations on it.

Please help me. I tried to do it for hours but unsuccessful with the preg_match

regards
Aditya
Link to comment
https://forums.phpfreaks.com/topic/35551-small-preg_match-help-needed/
Share on other sites

No i am a completely noob in this matter. I just played with it a bit reading tutorials etc thinking that i would be able to do it.

preg_match("/^(<h5>Page 1 of )|(results</h5>)$/", "$test", $matches);
echo "$matches[2]";

Thats what a n00b can write  ;D ;D ;D

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.