php - Get respective part from string

140

Kindly let me know how to get the partApplication6.docx from strings likefiles/abcd/Application6.docx ?

In simple words I am just trying to get the file name along with its extensionApplication6.docx

Note:files/abcd/ can be differentppt/file/ so I cannot use the trick of replacingfiles/abcd/

586

Answer

Solution:

You can use basename to get what you want.

$file = basename("files/abcd/Application6.docx");
274

Answer

Solution:

Hope This Helps :)

<?php
     $url = "http://test.com/beta/files_images/file.php";
     $keys = parse_url($url); // Parse the url
     $data = explode("/", $keys['path']); 
     $last = end($data); 
 ?>

People are also looking for solutions to the problem: include - Including files in index.php (Fat-Free Framework)

Source

Didn't find the answer?

Our community is visited by hundreds of web development professionals every day. Ask your question and get a quick answer for free.

Ask a Question

Write quick answer

Do you know the answer to this question? Write a quick response to it. With your help, we will make our community stronger.

Similar questions

Find the answer in similar questions on our website.