473,406 Members | 2,336 Online
Bytes | Software Development & Data Engineering Community
Post Job

Home Posts Topics Members FAQ

Join Bytes to post your question to a community of 473,406 software developers and data experts.

Problem in understanding php code

6
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 :

Expand|Select|Wrap|Line Numbers
  1. <?php
  2. $tt = "Corn Futures (CZ)";
  3. echo "<SPAN class='tt'>".$tt."</SPAN>";
  4. $rowspr = 0;
  5. $outmode = 0;
  6. $dataavl = 0;
  7. $hand = fopen("http://www.cbot.com/cbot/pub/page/0,3181,793,00.html",r);
  8.  
  9. while (!feof($hand)) {
  10.       $buffer = fgetss($hand, 4096,"<table><th><tr><td><br><ul><li>");
  11.  
  12.     if(strpos($buffer, "<table width='650' border='0' cellpadding='3' cellspacing='0' class='tableright'>")!==false){$outmode = 1;$dataavl = 1;}
  13.  
  14.     if(strpos($buffer, "<tr class='dataDetails")!==false){$rowspr = $rowspr + 1;}
  15.     if($rowspr == 4){$outmode = 0;echo "</table>"; $rowspr = $rowspr + 1;}
  16.  
  17.  
  18.     if($outmode == 1)
  19.     {
  20.     $buffer = str_replace("= Chart","",$buffer);
  21.     $buffer = str_replace("= Option","",$buffer);
  22.       echo $buffer;
  23.          if(strpos($buffer, "</table>")!==false){$outmode = 0;}
  24.     }
  25.     }
  26. fclose($hand);
  27. if($dataavl == 0){echo "<br><i>Data is currently not available.</i>";}
  28. ?>
  29.  
  30. &nbsp;<br>
  31. &nbsp;<br>
  32. &nbsp;<br>
  33.  
  34. <?php
  35. $tt = "Ethanol Futures (EZ)";
  36. echo "<SPAN class='tt'>".$tt."</SPAN>";
  37. $rowspr = 0;
  38. $outmode = 0;
  39. $dataavl = 0;
  40. $hand = fopen("http://www.cbot.com/cbot/pub/page/0,3181,1754,00.html",r);
  41.  
  42. while (!feof($hand)) {
  43.       $buffer = fgetss($hand, 4096,"<table><th><tr><td><br><ul><li>");
  44.  
  45.     if(strpos($buffer, "<table width='650' border='0' cellpadding='3' cellspacing='0' class='tableright'>")!==false){$outmode = 1;$dataavl = 1;}
  46.  
  47.     if(strpos($buffer, "<tr class='dataDetails")!==false){$rowspr = $rowspr + 1;}
  48.     if($rowspr == 4){$outmode = 0;echo "</table>"; $rowspr = $rowspr + 1;}
  49.  
  50.  
  51.     if($outmode == 1)
  52.     {
  53.     $buffer = str_replace("= Chart","",$buffer);
  54.     $buffer = str_replace("= Option","",$buffer);
  55.       echo $buffer;
  56.          if(strpos($buffer, "</table>")!==false){$outmode = 0;}
  57.     }
  58.     }
  59. fclose($hand);
  60. if($dataavl == 0){echo "<br><i>Data is currently not available.</i>";}
  61. ?>
  62.  
can anybody make me understand of this code.
Jan 8 '10 #1
5 1984
Dormilich
8,658 Expert Mod 8TB
in short, they read a website and extract data from a HTML table.
Jan 8 '10 #2
vtp82
6
Thanks for reply but they read data from all HTML Tables or any specific table from that HTML Source.
Jan 9 '10 #3
Dormilich
8,658 Expert Mod 8TB
any table that starts like defined in line #45
Jan 9 '10 #4
vtp82
6
You mean table which is defined only on line #45. no other tables have been read ?
Jan 11 '10 #5
Dormilich
8,658 Expert Mod 8TB
basically, yes. That’s what the code says.
Jan 11 '10 #6

Sign in to post your reply or Sign up for a free account.

Similar topics

4
by: Jole | last post by:
Hi I'm using serialization to read in an object from a file. My code basically does this: 1)MyClass obj = (MyClass) in.readObject(); ('in' is an ObjectInputStream wrapped around a...
4
by: Me | last post by:
I am not understanding an aspect of how to implement a class template in a ..cpp file. What I do know is that there are at least two problems with my understanding of how to accomplish the...
12
by: Torbjørn Pettersen | last post by:
I'm having problems validating my HTML code because of some ASP code I'm using: ---Start Code--- <% If rs("Average") = 0 Then VotingImage = "<img src="/images/0.gif" alt='No votes yet'>"...
4
by: Bangalore | last post by:
Hi all, I am finding quite difficulty in understanding the behaviour of the following program. Base class is singleton, so it should allow the creation of only one object. Eventhough it is...
17
by: Phil McKraken | last post by:
I am having a problem putting together a shopping cart with the below script. Everything displays fine, adds totals fine, and works perfect EXCEPT if you choose the 9.95 item #5 BY ITSELF the total...
37
by: Patrik Huber | last post by:
Hello! I got the following Code in Assembler (NASM), which prints out "5" in realmode: mov ax, 0xB800 mov es, ax mov byte , '5' I want to do the same in gcc now, but I'm stuck. GCC...
57
by: Xarky | last post by:
Hi, I am writing a linked list in the following way. struct list { struct list *next; char *mybuff; };
1
by: Andrew | last post by:
Hey all, Working on revamping our Intranet here and making use of the LDPA, Active Directory, Directory Services, etc. that .Net provides. I am still fairly new on this subject, so the problem...
9
by: rn5a | last post by:
A Form has a DataGrid which displays records from a SQL Server 2005 DB table. Users can modify the records using this DataGrid for which I am using EditCommandColumn in the DataGrid. This is the...
11
by: eBob.com | last post by:
I have this nasty problem with Shared methods and what I think of as "global storage" - i.e. storage declared outside of any subroutines or functions. In the simple example below this "global"...
0
by: Charles Arthur | last post by:
How do i turn on java script on a villaon, callus and itel keypad mobile phone
0
by: emmanuelkatto | last post by:
Hi All, I am Emmanuel katto from Uganda. I want to ask what challenges you've faced while migrating a website to cloud. Please let me know. Thanks! Emmanuel
1
by: nemocccc | last post by:
hello, everyone, I want to develop a software for my android phone for daily needs, any suggestions?
0
by: Hystou | last post by:
There are some requirements for setting up RAID: 1. The motherboard and BIOS support RAID configuration. 2. The motherboard has 2 or more available SATA protocol SSD/HDD slots (including MSATA, M.2...
0
by: Hystou | last post by:
Most computers default to English, but sometimes we require a different language, especially when relocating. Forgot to request a specific language before your computer shipped? No problem! You can...
0
by: Hystou | last post by:
Overview: Windows 11 and 10 have less user interface control over operating system update behaviour than previous versions of Windows. In Windows 11 and 10, there is no way to turn off the Windows...
0
tracyyun
by: tracyyun | last post by:
Dear forum friends, With the development of smart home technology, a variety of wireless communication protocols have appeared on the market, such as Zigbee, Z-Wave, Wi-Fi, Bluetooth, etc. Each...
0
agi2029
by: agi2029 | last post by:
Let's talk about the concept of autonomous AI software engineers and no-code agents. These AIs are designed to manage the entire lifecycle of a software development project—planning, coding, testing,...
0
isladogs
by: isladogs | last post by:
The next Access Europe User Group meeting will be on Wednesday 1 May 2024 starting at 18:00 UK time (6PM UTC+1) and finishing by 19:30 (7.30PM). In this session, we are pleased to welcome a new...

By using Bytes.com and it's services, you agree to our Privacy Policy and Terms of Use.

To disable or enable advertisements and analytics tracking please visit the manage ads & tracking page.