newbtophp Posted March 3, 2010 Share Posted March 3, 2010 Im looping through an array of $_FILES using foreach, and then preg_matching that using if else, if found then run a function on that, however when i have more than 1 file and a match is found and the function runs, it outputs a fatal error can not redeclare function error Im not not sure why its doing this since its not the same file... This only happens when more than one file (even though they are different files) call the same function when looping. Here the code: if(count($_FILES["item_file"]['name'])>0) { //check if any file uploaded $GLOBALS['msg'] = ""; //initiate the global message for($j=0; $j < count($_FILES["item_file"]['name']); $j++) { //loop the uploaded file array $file_name = $_FILES["item_file"]['name']["$j"]; //file name $file = file_get_contents($_FILES["item_file"]['tmp_name']["$j"]); if(preg_match("~php~", $file)){ echo php($file); } else if(preg_match("~pl~", $file)){ echo perl($file); } } } } Any can help me, please. Quote Link to comment https://forums.phpfreaks.com/topic/194035-fatal-error-when-looping/ Share on other sites More sharing options...
teamatomic Posted March 3, 2010 Share Posted March 3, 2010 You're not showing all the code. None of what you do show is the problem. HTH Teamatomic Quote Link to comment https://forums.phpfreaks.com/topic/194035-fatal-error-when-looping/#findComment-1021027 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.