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 8884673
In Process

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 14, 20262026-06-14T21:07:07+00:00 2026-06-14T21:07:07+00:00

i have also got a similar question. I have an array where i need

  • 0

i have also got a similar question. I have an array where i need to extract parts from the keys of array and combine them. can you please suggest the best way for it.

$myarray=Array(
[0]=>'unwanted text'

[1]=>'unwanted+needed part1'

[2]=>'needed part2'

[3]=>'needed part3'

[4]=>'unwanted text'

)

how can i extract only the needed parts and combine them. Thanks a lot ahead.

  • 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-14T21:07:09+00:00Added an answer on June 14, 2026 at 9:07 pm

    Not exactly sure if this does what you want, but looping and copying to a new array should basically achieve your result (once you clarify how you decide which part of the strings are needed or unwanted)

    $myarray = array(…);
    $new_array = array();
    $unwanted = 'some_string';
    foreach($myarray as $k => $v) {
      $new_value = preg_replace("/^$unwanted/", '', $v); # replace unwanted parts with empty string (removes them);
      if(!empty($new_value)) { # did we just remove the entry completely? if so, don't append it to the new array
        $new_array[] = $v; # or $new_array[$k] if you want to keep indices.
      }
    }
    

    Assuming you want to join array entries and have a string as result, use the implode function of PHP: $string = implode(' ', $new_array);

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

Sidebar

Related Questions

I have asked a similar question here and got some answers, so first of
Similar to this question , I need to group a large number of records
I have to extract sections of an array and set the chunk to another
I've asked a similar question before, but I've got a more specific question about
I previously asked a similar question on this topic a while back and got
I asked a similar question earlier here , and it got me down the
I posted a similar question yesterday with the same code, I have rewritten and
I have also tried .('refresh') and .page() to no avail. The text-box updates but
I have a website that has one database I have also Desktop apps that
I have installed python 32 package to the C:\python32 I have also set the

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.