ShiVer Posted April 28, 2006 Share Posted April 28, 2006 Alright, I'm making this way to complicated on myself so hopefully someone with a fresh start could help.Heres the plan:I have several files in a directory.I want to open and read the directory to only find text files.The text files are setup in the following format: [b]picture.jpg|Title of Clip|clip.flv[/b]"[i]foreach[/i]" text file I want to explode to an array so I can show it like the following:HTML>>[code]-------------| | Title of clip| picture || |-------------[/code]The image and title will be a hyperlink so that when clicked it will open up another text document set by myself and write to it the clip.flvNote: So basically it's like uploading the information to a database and then using a while loop to pull it out and show all the results. The situation being the way it is I don't have access to a DB so I'm trying to use flatfile.I know most of you are probably lost now so please ask any questions and I'll do my best to answer! Thanks!- Ryan Quote Link to comment Share on other sites More sharing options...
zq29 Posted April 28, 2006 Share Posted April 28, 2006 You could try something like this...[code]<?php//Loop through all text files in a directoryforeach(glob("path/to/files/*.txt") as $file) { $content = file($file); //Loop through each line in the file foreach($content as $line) { //Seperate the line by the pipe symbol into an array and display $temp = explode("|",$line); echo "<p>Image: $temp[0]<br/>Title: $temp[1]<br/>Flash: $temp[2]</p>"; }}?>[/code] Quote Link to comment Share on other sites More sharing options...
wisewood Posted April 28, 2006 Share Posted April 28, 2006 This will get you on your way.[code]// open only text files in the current directoryforeach (glob("*.txt") as $filename) {echo $filename<br>";}[/code] Quote Link to comment Share on other sites More sharing options...
kenrbnsn Posted April 28, 2006 Share Posted April 28, 2006 This answer assumes that all the text files are named "something.txt"[code]<?phpforeach(glob(*.txt) as $textfile) { $tmp = file($textfile); list($pic, $title, $clip) = explode(trim($tmp[0])); list($w, $h, $t, $attr) = getimagesize($filename); echo '<img src="' . $pic . '" ' . $attr . '><a href="' . $clip . '">' . $title . '</a><br>';}?>[/code]Ken Quote Link to comment Share on other sites More sharing options...
ShiVer Posted April 28, 2006 Author Share Posted April 28, 2006 Thank you all, I got SemiApocalyptic's to work but I used kenrbnsn's.[b]@kenrbnsn[/b]: Ya forgot the seperation parameter in explode. lolThanks again to all three of ya. I'll be set for the next time I need to do somethin like this as well!- Ryan Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.