jesushax Posted June 9, 2008 Share Posted June 9, 2008 i know how to use the following function but was wondering what any of you would suggest for a quick method when i upload files i save the file type and then call the file type when viewign them and they come out like below i want to change application/msword TO Word Document application/pdf TO PDF Document image/pjpeg TO Image File now i know the long way to do this, would be to have if statements then ouptut the answer in a variable but can anyone offer a quicker neater solution? Cheers Link to comment https://forums.phpfreaks.com/topic/109405-solved-strreplace/ Share on other sites More sharing options...
craygo Posted June 9, 2008 Share Posted June 9, 2008 you can use an array then use array_search. Keep in mind array_search will return the key not the value. <?php $array = array("Word Document" => "application/msword", "PDF Document" => "application/pdf"); $type = "application/msword"; $doc = array_search($type, $array); echo $doc; ?> Ray Link to comment https://forums.phpfreaks.com/topic/109405-solved-strreplace/#findComment-561184 Share on other sites More sharing options...
jesushax Posted June 9, 2008 Author Share Posted June 9, 2008 Smashing Thanks Link to comment https://forums.phpfreaks.com/topic/109405-solved-strreplace/#findComment-561187 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.