PHP + MySQL - Match first letter of directory
- by user1822825
Let's say I have a class table. In the class table, there are many students with their pictures. In the first registration, I've registered the class and students with pictures. The pictures were put into a directory like classid_classname. Then, I change the class name. Now, I'm adding the student's picture. Now, the new picture can't be recognized because the class name has changed. The pic url will be set as classid_class(new)name. How can I match the first letter of the directory? This is my update code :
$classID= $_POST["classID"];
$className= $_POST["className"];
$p1 = $_FILES['p1']['name'];
$p2 = $_FILES['p2']['name'];
$p3 = $_FILES['p3']['name'];
$direct = $_POST["className"];
$direct = strtolower($direct);
$direct = str_replace(' ', '_', $direct);
$tfish = $classID."_".$direct; //the directory variable will have new name
because it can't be fetched if the directory has been changed many times//
$file = "slider_imagesClass/".$tfish."/";
$url = "/".$tfish."/";
How can I make the variable to match the first letter of the directory because the classID will not change? Thank you. Really appreciate your help :D