Parsing a string line-by-line in PHP
OK, here's my question: I'm redesigning my webpage in PHP, but I've got a problem. The way I have my pages set up is I have a directory filled with pages for that "section". The list of stuff for that section is filled out with a directory listing (and maybe this would work better with a mysql setup, but then I'd have to get into authentication and stuff too), but anyway.
My question is how can I parse a string line by line. What I'd like to do (and mind you this is largely psuedo-code) is this:
Once again, if someone could point me to a good tut on creating forms and stuff so I could use my mysql server and a content-mangment system of my own creation, that would be even greater.... yeah.
but anyway, thanks in advance.
For tutorials on the web, do a search on 'php mysql tutorial'.
I tought myself using a series on sitepoint.com; could not find it anymore on their site (previous time I checked it was no longer complete), but this is the same article (also incomplete). Although incomplete, it might get you started.
PHP and MySQL Web Development by Luke Wlling and Laura Thomson; isbn 0-67232-525-X
Sams Teach Yourself PHP, MySQL and Apache by Julie C. Meloni; isbn 0-67232-620-5
Personally I think the first book is very good. The second one is less comprehensive but might get you going a little quicker.
I still use both.
For an example of directory listing, see http://evoluted.net/archives/2005/08...ry_listi_2.php. I've used it once with success (no use of thumbnails).
Or search the web for 'directory listing php'
The php manual suggest the following snippet of code:
You can then build a loop looking for the files, using is_file() and directories using is_dir()
If you're reading the data from a file, you can read it a line at a time pretty easily. See the file handling funcs in the php manual.
If you've got the whole string in memory you can split it into lines by doing an explode("\n",$string), and then loop through the resulting array.
|All times are GMT -5. The time now is 05:08 PM.|