seeder.us Posted September 22, 2012 Share Posted September 22, 2012 I'm having a problem with the following code My problem is i want to limit characters from $file, how can limit [HorribleSubs]_YuruYuri_S2_07_[480p].mkv.qt.mp4 into [HorribleSubs]_YuruYuri... not necessary for this file above but for every single file that is being echo $file I've tried to add it by my self but so far i do not understand it fully like this if ($rest = substr("$file", -1); <?php $count = 0; if ($handle = opendir('public')) { while (false !== ($file = readdir($handle))) { if ($file != "." && $file != ".." [color=#000000][color=#0000BB] if ($rest [/color][color=#007700]= [/color][color=#0000BB]substr[/color][color=#007700]([/color][color=#DD0000]"[/color][/color]$file[color=#000000][color=#DD0000]"[/color][color=#007700], -[/color][color=#0000BB]1[/color][color=#007700]);[/color][/color] && substr($file,-strlen(".html")) != ".html" //if you don't want to include .html files, for instance && substr($file,-strlen(".jpg")) != ".jpg" //if you don't want to include .js files, for instance && substr($file,-strlen(".sh")) != ".sh" //if you don't want to include .js files, for instance && substr($file,-strlen(".srt")) != ".srt" //if you don't want to include .js files, for instance && substr($file,-strlen(".sub")) != ".sub" //if you don't want to include .js files, for instance && substr($file,-strlen("subs")) != "subs" //if you don't want to include .js files, for instance && substr($file,-strlen("png")) != "png" //if you don't want to include .js files, for instance && $file != "" ) {$count++; print(" <div class=\"related\"><ul> <a href=\"http://$get_domain/play.php?url=http://$get_domain/public/$file\" title=\"$file\"><li> <img src=\"http://$get_domain/public/$file.png\" style=\"width:60px; height:50px; float:left; margin-right:6px; border:0;\"> $file<br /> <span class=\"detail\">5,432,128 views</span> </li></a> \n"); } } closedir($handle); } ?> Quote Link to comment https://forums.phpfreaks.com/topic/268655-php5-and-substr-problem/ 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.