 Okay, continuing with our tutorial on PHP. These are just quick little nuggets of information. I just create a folder. I'll list out. I've got some files in there with different names. You can see them in here in my web browser as well. There's a folder called Files. Click it, and there are the files. Today we're going to learn how to use PHP to list all the files within the directory and actually put them in a loop which later on could be useful for manipulating or retrieving information from those files. Let me go back to my main folder here. We're going to create a file. We'll call it ls.php. I am going to create my PHP tags here. Just like with the reading from files, we did a for each item within a particular array in most cases. We are going to do something. We're going to create a variable and then run it line by line. We're going to start off with for each here. I'm going to put the curly braces here just to open and close my for loop so I don't forget later on. In the previous one, we created an array that was a line from a file. Here we're going to use the glob function. We're going to pass the information here. Our folder was files. We're going to say ford slash. I'm just going to put a asterisk there so that we can list all the files. I'm going to say as dollar sign file name. For each file in there, we're going to create a variable called file name. For each one, we're going to echo out, let's say dollar sign, file name, new line. Don't forget our semi-column there. I believe we are done with our code here. I'll come in here. There's our list.php. When I click that, it will run. You can see each of the files listed out. We got the folder name, ford slash, file one, file two, file three, file three, or some have text as extension, some have JPEG as an extension, which is the next part of this little tutorial. Let's say we just wanted to see the text files. Very simple. It might be a little obvious to you at this point. Just put in the txt like that. Save and I will f5 up here. Now we're only looking at files with the extension of txt. If I change that to JPEG, we got a list of all our JPEGs. We could also do something like this, just to make the story a little bit longer. I'll say echo, and I will say header one, close it, and we'll say JPEG files. And then what we'll do here, just to save time, I'm going to copy and paste that. And I will say here, text files. Let's see. So now it's going to display the header of JPEG files. And then it will run through the loop for each JPEG file, and then it will do the header for text files, and then run through the loop for each text file. So let's f5 here, and I have an error here, and that is because in both cases here, I forgot to put my semicolon. Once again, it does tell you the error that you hit there, and we hit the second error once I fixed the first one. So there we go. We got JPEG files. Boom. And we got text files listed. Boom. So there we go. We have listed files out, and we've also done it by extensions. Once again, I hope you're enjoying these PHP tutorials. If you are, give these videos thumbs up, comments, let me know. Once again, this is all working towards a goal of making mostly web applications, but you can do them to at least seem like standalone applications. Obviously, if we're working with PHP, you would need a server. But this is going to be great for making applications that just run everywhere without, with very little work to no work, you know, as far as porting, because everything we're using are scripting languages, and those that are on server side, well, you're in control of the server, and those that are on client side are fully compatible with pretty much every modern operating system. So thank you once again for watching. Visit filmsbychris.com, that's Chris the K. Should be a link in description. Should also be an annotation to this entire playlist for PHP. And I just hope that you're enjoying these. I hope that you have a great day.