Jump to content

split to preg_split need help please


SnakZ

Recommended Posts

can anyone tell me if this is the right way to rewrite this split  ??

 

$exts = split("[/\\.]", $q) ;

to

$exts = preg_split("[\\.]", $q) ;

 

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

 

 

ty you for any help with this

Link to comment
https://forums.phpfreaks.com/topic/227805-split-to-preg_split-need-help-please/
Share on other sites

Forward slash and period, right?

'#[/.]#'

 

But if you're pulling a filename extension,

substr(strrchr($string, "."), 1)

(or one of a billion other methods that don't involve arrays)

 

yeah im pulling the file extension to see if its the right ext for uploading

 

but im not to sure how your code works or how to even input it into the the function

sorry this function is something i grab off a php helper site so im not sure how it works :(

Archived

This topic is now archived and is closed to further replies.

×
×
  • Create New...

Important Information

We have placed cookies on your device to help make this website better. You can adjust your cookie settings, otherwise we'll assume you're okay to continue.