Problem in understanding php code

Collapse
X
 
  • Time
  • Show
Clear All
new posts
  • vtp82
    New Member
    • Oct 2007
    • 6

    Problem in understanding php code

    I am vaibhav here i am a .net developer. I need help if anybody can I am having one php code that I need to convert in asp.net. but I do not understand what actually they had done in php so if anybody can explain that what have they done then I can convert it.

    Php code is as follows :

    Code:
    <?php
    $tt = "Corn Futures (CZ)";
    echo "<SPAN class='tt'>".$tt."</SPAN>";
    $rowspr = 0;
    $outmode = 0;
    $dataavl = 0;
    $hand = fopen("http://www.cbot.com/cbot/pub/page/0,3181,793,00.html",r);
    
    while (!feof($hand)) {
          $buffer = fgetss($hand, 4096,"<table><th><tr><td><br><ul><li>");
            
    	if(strpos($buffer, "<table width='650' border='0' cellpadding='3' cellspacing='0' class='tableright'>")!==false){$outmode = 1;$dataavl = 1;}
    
    	if(strpos($buffer, "<tr class='dataDetails")!==false){$rowspr = $rowspr + 1;}
    	if($rowspr == 4){$outmode = 0;echo "</table>"; $rowspr = $rowspr + 1;}
    
    
    	if($outmode == 1)
    	{
    	$buffer = str_replace("= Chart","",$buffer);
    	$buffer = str_replace("= Option","",$buffer);
          echo $buffer;
         	if(strpos($buffer, "</table>")!==false){$outmode = 0;}
    	}
        }
    fclose($hand);
    if($dataavl == 0){echo "<br><i>Data is currently not available.</i>";}
    ?>
    
    &nbsp;<br>
    &nbsp;<br>
    &nbsp;<br>
    
    <?php
    $tt = "Ethanol Futures (EZ)";
    echo "<SPAN class='tt'>".$tt."</SPAN>";
    $rowspr = 0;
    $outmode = 0;
    $dataavl = 0;
    $hand = fopen("http://www.cbot.com/cbot/pub/page/0,3181,1754,00.html",r);
    
    while (!feof($hand)) {
          $buffer = fgetss($hand, 4096,"<table><th><tr><td><br><ul><li>");
            
    	if(strpos($buffer, "<table width='650' border='0' cellpadding='3' cellspacing='0' class='tableright'>")!==false){$outmode = 1;$dataavl = 1;}
    
    	if(strpos($buffer, "<tr class='dataDetails")!==false){$rowspr = $rowspr + 1;}
    	if($rowspr == 4){$outmode = 0;echo "</table>"; $rowspr = $rowspr + 1;}
    
    
    	if($outmode == 1)
    	{
    	$buffer = str_replace("= Chart","",$buffer);
    	$buffer = str_replace("= Option","",$buffer);
          echo $buffer;
         	if(strpos($buffer, "</table>")!==false){$outmode = 0;}
    	}
        }
    fclose($hand);
    if($dataavl == 0){echo "<br><i>Data is currently not available.</i>";}
    ?>
    can anybody make me understand of this code.
    Last edited by Markus; Jan 8 '10, 02:38 PM. Reason: Added [code] tags.
  • Dormilich
    Recognized Expert Expert
    • Aug 2008
    • 8694

    #2
    in short, they read a website and extract data from a HTML table.

    Comment

    • vtp82
      New Member
      • Oct 2007
      • 6

      #3
      Thanks for reply but they read data from all HTML Tables or any specific table from that HTML Source.

      Comment

      • Dormilich
        Recognized Expert Expert
        • Aug 2008
        • 8694

        #4
        any table that starts like defined in line #45

        Comment

        • vtp82
          New Member
          • Oct 2007
          • 6

          #5
          You mean table which is defined only on line #45. no other tables have been read ?

          Comment

          • Dormilich
            Recognized Expert Expert
            • Aug 2008
            • 8694

            #6
            basically, yes. That’s what the code says.

            Comment

            Working...