hello
I try to read from a data file some data into an array and print the last submited entries out on a page. ( last 25 classified entries here)
I got the script woring in ASP and now I try to convert it into php. I have not much expierence in php could somebody please convert this asp script into PHP or explain somethings like what I should use for \"dim array etc in php
This is the working code in asp
<%
Dim MyArray1(1000) \'allows up to 1000 lines from the file, change this if number is higher
Dim MyArray2, MyString, x, ObjDbFile, thisPath, thisFile, NumLines \'define the variables, it\'s good practice but not always followed 🙂
x=0
Set ObjDbFile=Server.CreateObject(\"Scripting.FileSystemObject\")
thisPath = Server.MapPath (\"Classifieds/data/ads.data\")
Set thisFile = ObjDbFile.OpenTextFile (thisPath, 1, True)
Do Until thisFile.AtEndOfStream \'read all of the file, and place in to an array.
x = x + 1 \'starts at 1 to make things easier
MyArray1(x) = thisFile.ReadLine
Loop
Set thisFile = Nothing \'close the text file, it\'s not needed from this point on
Set ObjDbFile = Nothing
NumLines = x
x=0
For x = NumLines-50 To NumLines \'start at 3rd from last line loop until all three have been written.
MyArray2 = Split(MyArray1(x),\"|\")
For y = 0 to UBOUND(MyArray2)\'gets total number of objects
entry = 0 \'put the entry number you want to display here. Just filters out unwanted info.
datum = 3
city = 13
topic = 21
what = 23
title = 24
If y = entry Then Response.Write(\"<table border=\"\"0\"\" width=\"\"100%\"\" valign=\"\"top\"\" align=\"\"center\"\" cellspacing=\"\"0\"\" cellpadding=\"\"0\"\">\") & CHR(13)
If y = datum Then Response.Write(\"<td width=\"\"8%\"\"><font face=\"\"Tahoma, Arial, Helvetica\"\" size=\"\"1\"\">\"&MyArray2(y))& \"</font></td>\" & CHR(13)
If y = city Then Response.Write(\"<td width=\"\"10%\"\" align=\"\"left\"\"><font face=\"\"Tahoma, Arial, Helvetica\"\" size=\"\"1\"\"><a href=\"\"browse.asp?Realm=Ontario&query=\"&MyArray2(y)&\"\"\"><acronym title=\"\"More Info about \"&MyArray2(y)&\"\"\">\"&MyArray2(y)& \"</a></font></td>\" & CHR(13))
If y = topic Then Response.Write(\"<td width=\"\"15%\"\" align=\"\"left\"\"><font face=\"\"Tahoma, Arial, Helvetica\"\" size=\"\"1\"\"><a href=\"\"Classifieds/classifieds.cgi?session_key=&keywords=\"&replace(MyArray2(y), \"&\", \" \")&\"&case_sensitive=&results_format=headlines&query=keyword_plus&search_and_display_db_button=Search%21&boolean=any+terms\"\"><acronym title=\"\"Classified Category \"&MyArray2(y)&\"\"\"><b>\"&MyArray2(y))& \"</a></font></td>\" & CHR(13)
If y = what Then Response.Write(\"<td width=\"\"12%\"\" align=\"\"left\"\"><font face=\"\"Tahoma, Arial, Helvetica\"\" size=\"\"1\"\">\"&MyArray2(y))& \"</font></td>\" & CHR(13)
If y = title Then Response.Write(\"<td width=\"\"25%\"\"align=\"\"left\"\"><font face=\"\"Tahoma, Arial, Helvetica\"\" size=\"\"2\"\"><a href=\"\"Classifieds/classifieds.cgi?session_key=&query=retrieval&search_and_display_db_button=on&db_id=\"&MyArray2(0)&\"\"\"><acronym title=\"\"Ad Detail \"&MyArray2(y)&\"\"\"><b>\"&MyArray2(y))& \"</a><br></font></b></td></table>\" & CHR(13)
Next
Next
%>
end asp code
Thank you for any help with this code