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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 11, 20262026-06-11T09:10:18+00:00 2026-06-11T09:10:18+00:00

array ( [0] => 3 / 4 Bananas [1] => 1 / 7 Apples

  • 0
array (    
    [0] => 3 / 4 Bananas
    [1] => 1 / 7 Apples
    [2] => 3 / 3 Kiwis
    )

Is it possible, to say, iterate through this list, and explode between the first letter and first integer found, so I could seperate the text from the set of numbers and end up with something like:

array (
   [0] => Bananas
   [1] => Apples
   [2] => Kiwis
   )

I have no idea how you would specify this as the delimiter. Is it even possible?

foreach ($fruit_array as $line) {
   $var = explode("??", $line);
}

Edit: updated example. exploding by a space wouldn’t work. see above example.

  • 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-11T09:10:20+00:00Added an answer on June 11, 2026 at 9:10 am

    You could use preg_match instead of explode:

    $fruit_array = array("3 / 4 Bananas", "1 / 7 Apples", "3 / 3 Kiwis");
    $result = array();
    foreach ($fruit_array as $line) {
       preg_match("/\d[^A-Za-z]+([A-Za-z\s]+)/", $line, $match);
       array_push($result, $match[1]);
    }
    

    It will almost literally match your expression, that is, a digit \d, followed by one or more non-letters [^A-Za-z], followed by one or more letters or whitespace (to account for multiple words) [A-Za-z\s]+. This final matched string, between parentheses, will be captured in the first match, i.e., $match[1].

    Here’s a DEMO.

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

Sidebar

Related Questions

I have a simple single-dimension array, let's say: fruits = [apples,bananas,oranges,peaches,plums]; I can loop
Let's say I have an array as follows: $food['fruit'] = array('apples','oranges','bananas'); $food['veg'] = array('potatoes','onions','peppers');
How do it turn a multidimensional array like: $fruits['apples']['blue'] = 24; $fruits['bananas']['blue'] = 12;
For example: $fruits = array( 1 => 'apples', 2 => 'lemons', 3 => 'bananas'
I have a simple array: arr = [apples, bananas, coconuts, watermelons] I also have
Say we have the following array of instantiated objects: SomeClass[] items = {new SomeClass(Apples,
Say I have a simple PHP loop like this one // Bad example $array
Array = [ {name:apples, price:3.99, tax:0.20}, {name:oranges, price:1.40, tax:0.15}, {name:bananas, price:0.99, tax:0.10}, ] How
var fruit = [apple,pear,pear,pear,banana]; How do I remove all pear fruit from this array?
I am trying to deserialize this JSON array into my android project. [{Name:Ban,Price:1},{Name:Banana,Price:1},{Name:chicken,Price:14},{Name:pizza,Price:16},{Name:slice,Price:1}] I

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.