php - Check what a variable ends with? -


i'm stuck in code.

my site's users supposed give me link of image store in variable. how can check link ends with, extension if will?

you can use of these:

$ext = substr(strrchr(filename, '.'), 1);  $ext = substr(filename, strrpos(filename, '.') + 1);  $ext = preg_replace('/^.*\.([^.]+)$/d', '$1', filename); 

their performance differences negligible (even when ran 500 000 times; tested php 7 using phpcb)

the pathinfo() like... slow, compared these, getting (last) extension.


Comments

Popular posts from this blog

javascript - jquery or ashx not working -

opencv - DataType<cv::detail::deriv_type>::depth what is it used for -

python 3.x - Mapping specific letters onto a list of words -