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

  • Home
  • SEARCH
  • 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 8847353
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T12:10:15+00:00 2026-06-14T12:10:15+00:00

I have an array of strings, each string containing the name of an image

  • 0

I have an array of strings, each string containing the name of an image file:

$slike=(1.jpg,253455.jpg,32.jpg,477.jpg);

I want new array, to look like this:

$slike=(1,253455,32,477);

How can I remove the file extension from each string in this array?

  • 1 1 Answer
  • 0 Views
  • 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-06-14T12:10:17+00:00Added an answer on June 14, 2026 at 12:10 pm

    If you’re working with filenames, use PHP’s built in pathinfo() function. there’s no need to use regex for this.

    <?php
    
    # your array
    $slike = array('1.jpg','253455.jpg','32.jpg','477.jpg');
    
    # if you have PHP >= 5.3, I'd use this
    $slike = array_map(function($e){
        return pathinfo($e, PATHINFO_FILENAME);
    }, $slike);
    
    # if you have PHP <= 5.2, use this
    $slike = array_map('pathinfo', $slike, array_fill(
        0, count($slike), PATHINFO_FILENAME
    ));
    
    # dump
    print_r($slike);    
    

    Output

    Array
    (
        [0] => 1
        [1] => 253455
        [2] => 32
        [3] => 477
    )
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I have two vectors containing strings. I want to compare each string of vector1
I have several string each containing a JSON representation of an array of objects.
I have a list of strings and with each string I want to check
I have an arrays.xml file containing quite a few string-array elements for use with
I have an array where I fill in the types as string of each
Currently, I have an array of Strings, each with random characters in it that
I have 4 string arrays,each of these array's length is 4. I also have
I have a For Each loop that is looping through an array of strings
I have array of strings, String[] data and it's 10 elements has value P
I have an array of strings var controlsToGet = new[] {lblHome,lblContact}; I have List<LanguageControl>

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.