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
Post a Comment