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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: May 26, 20262026-05-26T18:45:09+00:00 2026-05-26T18:45:09+00:00

Code: $testing=sniper this and sniper that; $connectors=array(‘and’, ‘now’, ‘but’, ‘still’, ‘so’, ‘only’, ‘therefore’, ‘moreover’,

  • 0

Code:

$testing="sniper this and sniper that";
$connectors=array('and', 'now', 'but', 'still', 'so', 'only', 'therefore', 'moreover', 'besides', 'consequently','nevertheless', 'for', 'however', 'hence', 'either', 'or', 'neither', 'nor', 'both', 'also','while', 'then', 'who', 'which', 'that', 'although', 'though', 'since', 'until', 'as', 'if','after', 'before', 'how', 'once', 'when', 'lest', 'why', 'unless', 'because', 'till', 'where', 'whether','the', 'a', 'an','about', 'above', 'across', 'after', 'against', 'along', 'among', 'around', 'at', 'before', 'behind','below', 'beneath', 'beside', 'between', 'beyond', 'but', 'by', 'despite', 'down', 'during', 'except','for', 'from', 'in', 'inside', 'into', 'like', 'near', 'of', 'off', 'on', 'onto', 'out', 'outside', 'over',
        'past', 'since', 'through', 'throughout', 'till', 'to', 'toward', 'under', 'underneath', 'until', 'up', 'upon','with', 'within', 'without','who', 'whom', 'whose', 'which', 'that', 'this', 'these', 'those', 'I', 'Me', 'You', 'He', 'him', 'she','her', 'it', 'we', 'us', 'they', 'them', 'Mine', 'Yours', 'His', 'Hers', 'Its', 'Ours', 'Theirs', 'whoever','whomever', 'whichever', 'myself', 'yourself', 'himself', 'herself', 'itself','ourselves', 'yourselves', 'themselves');

foreach($connectors as $word)
{
    $pattern="/".strtolower($word)."/";
    $data=preg_replace($pattern,"/ /", $testing);
}
echo $data."<br>";
echo $testing;

Output:

sniper this and sniper that

sniper this and sniper that

Expected output:

sniper this and sniper that

sniper sniper

What am I doing wrong?

  • 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-26T18:45:10+00:00Added an answer on May 26, 2026 at 6:45 pm

    Try with:

    $testing = "sniper this and sniper that";
    $connectors = array( /* your data */ );
    
    $output = implode(' ', array_diff(explode(' ', $testing), $connectors));
    

    Case insensitive way:

    $output = implode(' ', array_udiff(explode(' ', $testing), $connectors, 'strcasecmp'));
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I'm trying to be better about unit testing my code, but right now I'm
Any Java unit testing framework that supports writing unit testing code like this: Collection<AType>
I'm using the TPL but I'm finding it tricky unit testing code that uses
How are people unit testing code that uses Linq to SQL?
I am interested in your opinions on unit-testing code that uses Corba to communicate
I get this error, while I'm testing the code below: You have an error
I am testing some weird-looking CSS code that I wrote (I'm using a mix
I'm writing testing code that will automatically iterate thru all Q_PROPERTY's of widgets and
I'm testing code that is designed to detect when a child process has segfaulted.
I am testing code in a MVC HTML helper that throws an error when

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.