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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 21, 20262026-05-21T21:52:01+00:00 2026-05-21T21:52:01+00:00

I previously had some help with this matter from @HSZ but have had trouble

  • 0

I previously had some help with this matter from @HSZ but have had trouble getting the solution to work with an existing array. What im trying to do is explode quotes, make all words uppercase plus get each words index value and only echo the ones i define then implode. In simplest terms, always remove the 4th word within quotations or the 3rd and 4th… This could probably done with regex as well.

Example:

Hello [1] => World [2] => This [3] => Is [4] => a [5] => Test ) 6 only outputs the numbers i define, such as 1 – (Hello) and [2] – (World) leaving out [3], [4], [5] and [6] or This is a test leaving only Hello World, or 1 and [6] for Hello Test…

Such as:

echo $data[1] + ' ' + $data[6]; //Would output index 1 and 6 Hello and Test

Existing Code

if (stripos($data, 'test') !== false) {
$arr = explode('"', $data);

for ($i = 1; $i < count($arr); $i += 2) {
$arr[$i] = strtoupper($arr[$i]);    
$arr[$i] = str_word_count($arr, 1); // Doesnt work with array of course.
}

$arr = $matches[1] + ' ' + $matches[6];
$data = implode('"', $arr);
}
  • 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-05-21T21:52:02+00:00Added an answer on May 21, 2026 at 9:52 pm

    Assuming $data is 'Hello world "this is a test"', $arr = explode('"', $data) will be the same as:

    $arr = array (
      [0] => 'Hello World',
      [1] => 'This is a test'
    )
    

    If you want to do things with this is a test, you can explode it out using something like $testarr = explode(' ', $arr[1]);.

    You can then do something like:

    $matches = array();
    foreach ($testarr as $key => $value) {
       $value = strtoupper($value);
       if(($key+1)%4 == 0) { // % is modulus; the result is the remainder the division of two numbers. If it's 0, the key+1 (compensate for 0 based keys) is divisible by 4.
          $matches[] = $value;
       }
    }
    $matches = implode('"',$matches);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I had previously done some testing projects for Android, but now I have a
previously i had custom tableviewcell and was loading from Nib.in that i have specified
I have had trouble finding help in the matlab documentation and previous questions about
I have tried everything and this makes absolutely no sense! I previously had Less.js
I've searched a lot and I previously have had something similar working but I
I previously had a post on this issue that was resolved. However since rebuilding
I have a follow-up question regarding an issue I previously had on SO here
I have an application that uses CoreData. I previously had a class named Marker
Previously we had desktop applications but given the fact that accessing the server (either
Can someone help me please. I had replies to a similar question but am

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.