Return only a part of the PHP variable

Asked

Viewed 54 times

2

I have the following variable:

$imagem = "D:\Web\data\localweb\sites\site.com.br\crm\748064485.jpg";

I need to return only 748064485.jpg, however, I do not want and I do not have how to use the str_replace("D:\Web\data\localweb\sites\site.com.br\crm\", $imagem); because folders are different with each upload to the database.

How can I adjust it?

1 answer

11


You can use the function explode along with end

$imagem = "D:\Web\data\localweb\sites\site.com.br\crm\748064485.jpg";
$cut = explode("\\", $imagem);
echo end($cut);

Browser other questions tagged

You are not signed in. Login or sign up in order to post.