Sign Up

Sign Up to our social questions and Answers Engine to ask questions, answer people’s questions, and connect with other people.

Have an account? Sign In

Have an account? Sign In Now

Sign In

Login to our social questions & Answers Engine to ask questions answer people’s questions & connect with other people.

Sign Up Here

Forgot Password?

Don't have account, Sign Up Here

Forgot Password

Lost your password? Please enter your email address. You will receive a link and will create a new password via email.

Have an account? Sign In Now

You must login to ask a question.

Forgot Password?

Need An Account, Sign Up Here

Please briefly explain why you feel this question should be reported.

Please briefly explain why you feel this answer should be reported.

Please briefly explain why you feel this user should be reported.

Sign InSign Up

The Archive Base

The Archive Base Logo The Archive Base Logo

The Archive Base Navigation

  • SEARCH
  • Home
  • About Us
  • Blog
  • Contact Us
Search
Ask A Question

Mobile menu

Close
Ask a Question
  • Home
  • Add group
  • Groups page
  • Feed
  • User Profile
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Buy Points
  • Users
  • Help
  • Buy Theme
  • SEARCH
Home/ Questions/Q 1020633
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 16, 20262026-05-16T11:11:27+00:00 2026-05-16T11:11:27+00:00

I want to know the function that can perform the following operation $str =

  • 0

I want to know the function that can perform the following operation

$str = “uploads/file/file1.jpg”;

i want to slash the initial of the string uploads/file/ and just want to return file1.jpg as value.

i tried using str_replace(),

$str = "uploads/file/file1.jpg";

$str2 = str_replace("uploads/file"," ", $str);

echo $str;

this is not working, where i am going wrong?

EDIT : Silly me i was not noticing that i was trying to echo $str, sorry for this. it is working for me now.

BTW i want to know which method is better the above one or the basename();

  • 1 1 Answer
  • 1 View
  • 0 Followers
  • 0
Share
  • Facebook
  • Report

Leave an answer
Cancel reply

You must login to add an answer.

Forgot Password?

Need An Account, Sign Up Here

1 Answer

  • Voted
  • Oldest
  • Recent
  • Random
  1. Editorial Team
    Editorial Team
    2026-05-16T11:11:28+00:00Added an answer on May 16, 2026 at 11:11 am

    Use basename(): It is designed specifically to get the file name part out of a path.

    $str2 = basename("uploads/file/file1.jpg");  // Will return file1.jpg
    

    Also interesting (although not necessary in this examle) is pathinfo() which splits a string into four components: Directory, base name, file name, and extension.

    The equivalent to split URLs into their components is parse_url().

    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I know that __stdcall functions can't have ellipses, but I want to be sure
I want to know how and when can I use the exit() function like
i want to know what wordpress build-in function you will use when sanitizing specific
I want to know how to call Ajax function Recursively. My ajax code is
I want to know whether the PHP serialize function is 100% secure, also if
I want to know How JQuery assign function name to $ ?
I want to know how to pass structures to another function and subsequently access
Hi I want to know what is the time complexity of the replaceAll function
I am using the MySQL GROUP BY function, and want to know if there
As I understand it, the JQuery load() function retrieves a document and can perform

Explore

  • Home
  • Add group
  • Groups page
  • Communities
  • Questions
    • New Questions
    • Trending Questions
    • Must read Questions
    • Hot Questions
  • Polls
  • Tags
  • Badges
  • Users
  • Help
  • SEARCH

Footer

© 2021 The Archive Base. All Rights Reserved
With Love by The Archive Base

Insert/edit link

Enter the destination URL

Or link to existing content

    No search term specified. Showing recent items. Search or use up and down arrow keys to select an item.