Skip to content

Instantly share code, notes, and snippets.

@littlefuntik
Created April 3, 2019 18:00
Show Gist options
  • Save littlefuntik/0c9edbd6b4150f0d7295293129507198 to your computer and use it in GitHub Desktop.
Save littlefuntik/0c9edbd6b4150f0d7295293129507198 to your computer and use it in GitHub Desktop.
Add filename prefix. "/a/b/c/abc.jpg" to "/a/b/c/abc-thumb.jpg"
<?php
$path = '/a/b/c/abc.jpg';
$path_new = substr( $path, 0, strrpos( $path, '.' ) ) . '-thumb' . substr( $path, strrpos( $path, '.' ) );
var_export( $path_new );
// Output: /a/b/c/abc-thumb.jpg
Sign up for free to join this conversation on GitHub. Already have an account? Sign in to comment