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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T02:50:59+00:00 2026-06-13T02:50:59+00:00

I am currently working on a VERY simple search feature for my website. The

  • 0

I am currently working on a VERY simple search feature for my website. The user types in their search query and then they are taken to a page that displays the results. In my case, the users are search for other users. My problem is, how do I separate a string into two variables?

Example Query:

Matt Morris

I would like my PHP to separate the string where the space occurs. How can I do that?

  <html>
    <form method="get" action="results.php">
        <input type="text" name="search"/>
    </form>

 </html>

<?php

    // code to explode the string into $fname and $lname 
       if there is a space present

$fname= Matt
$lname= Morris

if (isset($fname) && isset($lname)) {
$search_query= "SELECT * FROM users WHERE fname LIKE %'".$fname."'% AND lname LIKE  
%'".$lname."'%";
// code to run the query and display results
}
else if (isset($fname)) {
$search_query= "SELECT * FROM users WHERE fname LIKE %'".$fname."'%";
// code to run the query and display results
}
else if (isset($lname)) {
$search_query= "SELECT * FROM users WHERE lname LIKE %'".$lname."'%";
// code to run the query and display results
}

 ?>

Thanks

  • 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-13T02:50:59+00:00Added an answer on June 13, 2026 at 2:50 am

    You could do it like this:

    list($first, $last) = explode($name, ' ', 2);
    
    • 0
    • Reply
    • Share
      Share
      • Share on Facebook
      • Share on Twitter
      • Share on LinkedIn
      • Share on WhatsApp
      • Report

Sidebar

Related Questions

I am currently working on my portfolio website which uses a very simple navigation.
Currently I'm prototyping search with Lucene.Net-2.0-004 on a web application. It's working very well,
Currently, I am working on the very beginnings of a user database in MySQL
I think I have a very simple problem. I'm currently working on an API
I'm currently working on a very simple calendar using Jquery. Actually, We need a
I am currently working on building a very simple site for an open source
Good night, I am currently working on a very simple lexical analiser for human
A very good morning, i am currently working on a simple php project, the
We are currently working on a very simple Webapp, and we would like to
I'm currently working on a project in which I need a very simple editor

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.