I have a couple images in my images folder for example:
User12345_gallery0.png
User12345_profilePic.jpg
User12345_gallery1.png
User12345_gallery2.jpg
User54321_gallery0.png
What I'm trying to do is pass the user to my getimages.php and get that user's images. I've never done this before so I'm struggling with the syntax. Here's what I have so far:
if($_REQUEST['user']){
$ext = array('jpeg', 'png', 'jpg');
$dir = 'images/';
$user = $_REQUEST['user'];
$images = array();
foreach ($ext as $ex){
if (file_exists(strpos($dir.$user."_gallery", "gallery"))) {
//add file to $images???
}
}
}
I want to check if the file contains the username and the instance of "gallery". How can I do that? Am I on the right track?
file_exists()expects a file name andstrpos()returns a string offset.