Jump to content

In this example how does $quote get assigned it's value?


Canadian

Recommended Posts

In the example below I see how $pattern and $contents get assigned a value.  But I don't see where $quote gets it's value.  I'm guessing I don't fully understand the eregi() function.  Could someone dumb this down for me into a real world example?

 

Thanks.

 

 

 

<?php

  // choose stock to look at

  $symbol='AMZN';

  echo "<h1>Stock Quote for $symbol</h1>";

 

  $theurl="http://www.amex.com/equities/listCmp/EqLCDetQuote.jsp?Product_Symbol=$symbol";

 

  if (!($contents = file_get_contents($theurl)))

  {

    echo 'Could not open URL';

    exit;

  }

 

  // find the part of the page we want and output it

  $pattern = '(\\$[0-9 ]+\\.[0-9]+)';

 

  if (eregi($pattern, $contents, $quote))

  {

    echo "<p>$symbol was last sold at: ";

    echo $quote[1];

    echo '</p>';

  }

  else

  {

    echo '<p>No quote available</p>';

  };

 

 

  // acknowledge source

  echo '<p>'

      .'This information retrieved from <br />'

      ."<a href=\"$theurl\">$theurl</a><br />"

      .'on '.(date('l jS F Y g:i a T')).'</p>';

?>

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.