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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 13, 20262026-06-13T06:06:33+00:00 2026-06-13T06:06:33+00:00

(Programming Language: PHP v5.3) I am working on this website where I make search

  • 0

(Programming Language: PHP v5.3)

I am working on this website where I make search on specific websites using google and bing search APIs.

The Project:

A user can select a website to search from a drop-down list. We have an admin panel on this website. If the admin wants to add a new website to the drop-down list, he has to provide two sample URLs from the site as shown below.

Form Image

On the submit of form a code goes through input and generates a regex that we later use for pattern matching. The regex is stored in database for later use.

In a different form the visiting user selects a website from the drop-down list. He then enters the search “query” in a text box. We fetch results as JSON using search APIs(as mentioned above) where we use the following query syntax as search string:

“site:website query”
(where we replace “website” with the website user chose for search and replace “query” with user’s search query).

The Problem

Now what we have to do is get the best match of the url. The reason for doing a pattern match is that some times there are unwanted links in search results. For example lets say I search on website “www.example.com” for an article names “abcd”. Search engines might return these two urls:

1) http://www.example.com/articles/854/abcd
2) http://www.example.com/search/abcd

The first url is the one that I want. Now I have two issues to resolve.

1) I know that the code that I wrote to make a regex pattern from sample URLs is never going to be perfect considering that the admin adds websites on regular basis. There can never be enough conditions to check for creating a pattern for different websites from same code. Is there a better way to do this or regex is my only option?

2) I am developing on a machine running Windows 7 OS. preg_match_all() returns results here. But when I move the code to server which is running Linux OS, preg_match_all() does not return any results for the same parameters? I can’t seem to get why that is happening. Anyone knows why is this happening?

I have been working on web technologies for only past few weeks, so I don’t know if I have better options than regex. I would be very grateful if you could assist me or guide me towards resources where I can find solution for my problems.

  • 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-13T06:06:34+00:00Added an answer on June 13, 2026 at 6:06 am

    About question 1:
    I can’t quite grasp what you’re trying to accomplish so I can’t give any valid opinion.

    Regarding question 2:
    If both servers are running the same version of PHP, the regex library used ought to be the same. You can test this, however, by making a mock static file or string to test against the regex and see if the results are the same.

    Since you’re grabbing results from the search engines and then parsing them, the data retrieve might not be the same. Google/Bing change part of the data regarding the OS you use and that might alter preg results.

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

Sidebar

Related Questions

I'm working in PHP (but in this case I think the programming language doesn't
If you are working in PHP (or I guess any programming language) and using
What programming language and technology used to make the game at this page: http://www.mundijuegos.com/juegos/juego.php?juego=7&sala=13
I'm not familiar with this programming language,in PHP it's getcwd() .
I've started to learn OO programming, but using the PHP language with the help
Currently I am working with a commercial project with PHP. I think this question
Looking for something either using a programming language such as PHP or a desktop
I'm using PHP as my programming language. I really don't understand the use of
Hi, I am going to build a classifieds website using PHP/MySQL. This website is
Update: This question is a duplicate of Are there any programming languages targeting PHP,

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.