Ok, I am using cURL to pull stock data from MSN. So it can be displayed in a format I want. I have cURL up and pulling the first page. I want to be able to strip everything before the P/E and after.
Here is the start of my PHP code.
<?PHP
// Sets MSN Money URLs
$quote = "http://moneycentral.msn.com/detail/stock_quote?Symbol=";
$stock = MMM;
$ch = curl_init(); // initialize curl handle
curl_setopt($ch, CURLOPT_URL,$quote . $stock); // set url to post to
curl_setopt($ch, CURLOPT_FAILONERROR, 1);
curl_setopt($ch, CURLOPT_FOLLOWLOCATION, 1); // allow redirects
curl_setopt($ch, CURLOPT_RETURNTRANSFER,1); // return into a variable
curl_setopt($ch, CURLOPT_TIMEOUT, 3); // times out after 4s
$result = curl_exec($ch); // run the whole process
curl_close($ch);
echo $result;
?>
Here is a snipit of the results
Earnings/Share</td><td class="cl1">5.59</td></tr><tr><td>Forward P/E</td><td class="cl1">14.80</td></tr><tr><td>Market Cap.</td><td class="cl1">56.85 Bil</td></tr><tr><td>P/E</td><td class="cl1">14.40</td></tr><tr><td>Return on Equity</td><td class="cl1">37.74</td></tr>
One problem I can see is P/E shows up twice. Once as Forward P/E and then the P/E I want. Now I only need the number from the P/E, in this case it is 14.40. That is all I need. My problem is how to go about striping everything before and after the 14.40.