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 ?> Link to comment https://forums.phpfreaks.com/topic/147429-solved-array-of-issues/ 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 ) Link to comment https://forums.phpfreaks.com/topic/147429-solved-array-of-issues/#findComment-773819 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 Link to comment https://forums.phpfreaks.com/topic/147429-solved-array-of-issues/#findComment-773823 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 />'; } Link to comment https://forums.phpfreaks.com/topic/147429-solved-array-of-issues/#findComment-773826 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.