phpretard Posted March 1, 2009 Share Posted March 1, 2009 I am trying to take away "../documents/" and just end up with: $FinalArray = array("Agreement.doc","Overview.pdf"); At the end of the code I would like an array with these values: This code ain't workin'... <? $file_1="../documents/Agreement.doc"; $file_2="../documents/Overview.pdf"; $InputFile = array("Appraisal Agreement","Overview"); $files = array("$file_1","$file_2"); foreach($files as $filenames){ $ext = end(explode('.', $filenames)); $ext = substr(strrchr($filenames, '.'), 1); $ext = substr($filenames, strrpos($filenames, '.') + 1); $ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filenames); $exts = split("[/\\.]", $filenames); $n = count($exts)-1; $ext = $exts[$n]; $THE_EXT.$ext; } foreach($InputFile as $InputName){ $THE_NAME= $InputName; } $FinalArray = PROBLEM ?> Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 1, 2009 Author Share Posted March 1, 2009 This gets it close: $file_1="../documents/Appraisal Agreement.doc"; $file_2="../documents/Overview.pdf"; $InputFile = array("Appraisal Agreement","Overview"); $files = array("$file_1","$file_2"); foreach($files as $filenames){ $ext = end(explode('.', $filenames)); $ext = substr(strrchr($filenames, '.'), 1); $ext = substr($filenames, strrpos($filenames, '.') + 1); $ext = preg_replace('/^.*\.([^.]+)$/D', '$1', $filenames); $exts = split("[/\\.]", $filenames); $n = count($exts)-1; $ext = $exts[$n]; $THE_EXT[]= ".".$ext; } foreach($InputFile as $InputName){ $THE_NAME[]= $InputName; } $FinalArray = array_merge($THE_NAME, $THE_EXT); print_r ($FinalArray); Array ( [0] => Appraisal Agreement [1] => Overview [2] => .doc [3] => .pdf ) Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 1, 2009 Author Share Posted March 1, 2009 Even Closer... $Combine = array_combine($THE_NAME, $THE_EXT); print_r ($Combine); Array ( [Appraisal Agreement] => .doc [Overview] => .pdf ) // Actual Array ( [0] => Appraisal Agreement.doc [1] => Overview.pdf ) //NEEDED Quote Link to comment Share on other sites More sharing options...
phpretard Posted March 1, 2009 Author Share Posted March 1, 2009 Thank you me. foreach($Combine as $k=>$v){ echo $k.$v.'<br />'; } 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.