I know I am going about this the wrong way. Maybe someone can shed some light on this.
My project is reading info from an ldap server and then dynamically building pages. This much is working perfect!
I now want to build another html file for the index and am having a few problems. From my newbie book I found a way to create a bullet list from the directory. The problem is I need it sorted by file name.
Maybe the short answer here is learning to remote sort a directory prior to making the bullet list.
Unable to do this I did the following:
during my iteration with the ldap server I created an array of filenames. I then sorted this array using
sort(file_list);
I did a for loop with an echo and everything looks great. The problem is in building the page I have created a $index_file variable to hold all the html and while I can return individual values from the array without issue as $file_list[4]) , I cannot call my for loop and have it execute as code. It only resolves the variables and gives a text representation of the code.
Here is the code snippet:
$index_output = "
<HTML>
<HEAD>
<TITLE> $index_title </TITLE>
</HEAD>
<BODY>
for ($i=0;$i<$nelements;$i++) {
echo $file_list[$i];
}
<P>test</P>
</BODY>
</HTML>
";
and the output in index.html:
for (12=0;12<12;12++) { echo ; }
test
So is what I am doing completely stupid and should I just find a way to sort the remote directory by filename and then build my list?
Or can this code be made to work. I have spent a few hours playing with trying to create dynamic variables and assign data to the array from them then building a huge concatenation from these values and calling it in the html output, but I think I am going off the deep end here and need help from others.
Thanks,
Tony