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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 12, 20262026-06-12T16:16:04+00:00 2026-06-12T16:16:04+00:00

I writing a function to search within my database. I wanted to eliminate uneccessary

  • 0

I writing a function to search within my database. I wanted to eliminate uneccessary white spaces between words so I used preg_split. I have not used preg split before so I used print_r to see if it did what I was hoping for it to do (elimminate white spaces). Yet when I used print_r I got nothing back on my screen to show the array after I typed words in the search.

function search_results($keywords){
    $returned_results = array();
    $where = "";

    $keywords = preg_split('/[\s]+/', $keywords);
    print_r($keywords);

}

I would greatly appreciate it if someone could give me an idea as to what I did wrong, or better tips.

  • 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-12T16:16:05+00:00Added an answer on June 12, 2026 at 4:16 pm

    Tyr this

    $base_str = "this    is a   string  with multiple    spaces between  some words.            "; 
    
    
    $start = microtime(1); 
    for ($i=0; $i<100000; $i++){ 
        $string = $base_str; 
        while(strpos($string, '  ') !== false) 
        { 
             $string = str_replace('  ', ' ', $string); 
        } 
    } 
    
    echo $string;
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am writing a delete member function for a Binary Search Tree. I have
I'm writing a ajax search function using PHP. It's working correctly but have little
I'm writing an iterative function to search a binary tree for a certain value.
Hoping this is just a case of syntax. I'm writing a custom search function
I am writing a little function to resize my search div to stay the
I am writing a function short getBits(short data, int p, int n) I have
I'm writing a search function using Javascript, which is nearly finished and works fine
I'm having problems writing a php function to search for a certain text in
I am writing a searching function, and have thought up of this query using
I am writing a PHP/MYSQL search function which takes a users search query (as

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.