php - Cutting a string when it hits a dot -


this question has answer here:

i have variable called image_name. example below

$image_name = "hello.png"; 

i want cut string when see's dot. because want add randomised int name cant duplicated. example @ moment in code have

$image_name = substr($image_name, 0, 10) . time() . rand(0, 9999); 

and test string above return like

hello.png13953322416647 

my aim have string name equal hello13953322416647.png - showing .png after timestamp , random number

so know how cut string when hits dot in string , add @ end..?

thanks guys

i use pathinfo function. http://php.net/manual/en/function.pathinfo.php

$path_detail = pathinfo( $image_name ); $new_image_path = sprintf( "%s%s%s%s", $path_detail['filename'], time(), rand( 0,9999), $path_detail['extension']);  

Comments

Popular posts from this blog

java - WrongTypeOfReturnValue exception thrown when unit testing using mockito -

php - Magento - Deleted Base url key -

android - How to disable Button if EditText is empty ? -