Aggg Posted November 14, 2007 Share Posted November 14, 2007 My friend helped me to write this code show a random .swf-file: function file_extension($filename) { $tmparr = pathinfo($filename); return $tmparr['extension']; } function search_swf($path) { $dir = @opendir($path); $swf_files = array(); while ($file = readdir($dir)) { if (file_extension($file) == "swf") { array_push($swf_files,$file); } } closedir($dir); return $swf_files; } But I didn't quite understand, how can I get it to pick a file from directory /flash.. I think I need to write something after the $path-thing. But what? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 14, 2007 Share Posted November 14, 2007 how are you calling the function ? Quote Link to comment Share on other sites More sharing options...
Aggg Posted November 14, 2007 Author Share Posted November 14, 2007 Umm.. I really don't understand.. I'm not VERY familiar with php. That should be the only file besides the menu-header. Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 14, 2007 Share Posted November 14, 2007 I mean you have a function now you got to call it someway consider this code $strFilename = search_swf("uploads/"); print "uploads/$strFilename"; Quote Link to comment Share on other sites More sharing options...
Aggg Posted November 14, 2007 Author Share Posted November 14, 2007 Should I replace the "function search_swf($path)"-part with that? Quote Link to comment Share on other sites More sharing options...
rajivgonsalves Posted November 14, 2007 Share Posted November 14, 2007 can you post your code ? Quote Link to comment Share on other sites More sharing options...
aschk Posted November 14, 2007 Share Posted November 14, 2007 101 on functions - The following is the DEFINITION of a function : function mySpecialFunction($myVariable) { // Using $myVariable. echo $myVariable; } The following is the USE of the function we defined : mySpecialFunction("my name is Joe"); Quote Link to comment Share on other sites More sharing options...
Recommended Posts
Join the conversation
You can post now and register later. If you have an account, sign in now to post with your account.