0

Possible Duplicate:
Deprecated: Function split() is deprecated. How to rewrite this statement?

I'm getting a Deprecated: function split() is deprecated error on this code.

function getFileExt($filename) {
$filename = strtolower($filename) ;
$exts = split("[/\\.]", $filename) ;
$n = count($exts)-1;
$exts = $exts[$n];
return $exts; 

I'm meant to rewrite it or something but I have no idea how!

If somebody could help many thanks!

Community
  • 1
  • 1

2 Answers2

2

Try:

function getFileExt($filename) {
    $filename = strtolower($filename) ;
    $exts = explode(".", $filename) ;
    $n = count($exts)-1;
    $exts = $exts[$n];
    return $exts; 
}

The same just using explode on the ".".

Petar Sabev
  • 848
  • 6
  • 12
1

The function split is a old function. You can use explode to split.

http://www.php.net/explode

BrightIntelDusk
  • 4,577
  • 2
  • 25
  • 34
Jordi Kroon
  • 2,607
  • 3
  • 31
  • 55