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
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 :(

Link to comment
Share on other sites

This thread is more than a year old. Please don't revive it unless you have something important to add.

Join the conversation

You can post now and register later. If you have an account, sign in now to post with your account.

Guest
Reply to this topic...

×   Pasted as rich text.   Restore formatting

  Only 75 emoji are allowed.

×   Your link has been automatically embedded.   Display as a link instead

×   Your previous content has been restored.   Clear editor

×   You cannot paste images directly. Upload or insert images from URL.

×
×
  • 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.