corillo181 Posted December 6, 2006 Share Posted December 6, 2006 this code changes the name of a uploading filebut i dont know how it works can someone explaing it to me? i tried php.net but is not making sense .[code]$genre=$_POST['genre'];$filename = $_FILES['sfile']['name'];$pos = strrpos($filename, '.');$newname = $song . substr($filename, $pos);[/code] Link to comment https://forums.phpfreaks.com/topic/29612-strrpos-and-substr/ Share on other sites More sharing options...
willfitch Posted December 6, 2006 Share Posted December 6, 2006 Yes.The strrpos finds the position of the last occurance of a string and returns that value as an integer. substr truncates a string at position x (and y if specified). Like so:File Name: myfile.mpeg$pos = strrpos('myfile.mpeg','.'); // returns 6 (6th position)substr('myfile.mpeg',$pos); // removes everything except .mpegDo you understand? Link to comment https://forums.phpfreaks.com/topic/29612-strrpos-and-substr/#findComment-135886 Share on other sites More sharing options...
corillo181 Posted December 6, 2006 Author Share Posted December 6, 2006 yes! that's a clear answer, thank you. Link to comment https://forums.phpfreaks.com/topic/29612-strrpos-and-substr/#findComment-135891 Share on other sites More sharing options...
Recommended Posts
Archived
This topic is now archived and is closed to further replies.