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? Link to comment https://forums.phpfreaks.com/topic/77301-totally-noob-question-from-a-total-noob/ Share on other sites More sharing options...
rajivgonsalves Posted November 14, 2007 Share Posted November 14, 2007 how are you calling the function ? Link to comment https://forums.phpfreaks.com/topic/77301-totally-noob-question-from-a-total-noob/#findComment-391400 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. Link to comment https://forums.phpfreaks.com/topic/77301-totally-noob-question-from-a-total-noob/#findComment-391406 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"; Link to comment https://forums.phpfreaks.com/topic/77301-totally-noob-question-from-a-total-noob/#findComment-391408 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? Link to comment https://forums.phpfreaks.com/topic/77301-totally-noob-question-from-a-total-noob/#findComment-391420 Share on other sites More sharing options...
rajivgonsalves Posted November 14, 2007 Share Posted November 14, 2007 can you post your code ? Link to comment https://forums.phpfreaks.com/topic/77301-totally-noob-question-from-a-total-noob/#findComment-391422 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"); Link to comment https://forums.phpfreaks.com/topic/77301-totally-noob-question-from-a-total-noob/#findComment-391431 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.