PHP + MySQL - Match first letter of directory
        Posted  
        
            by 
                user1822825
            
        on Stack Overflow
        
        See other posts from Stack Overflow
        
            or by user1822825
        
        
        
        Published on 2012-12-08T16:53:25Z
        Indexed on 
            2012/12/08
            17:03 UTC
        
        
        Read the original article
        Hit count: 323
        
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
© Stack Overflow or respective owner