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

The Archive Base Latest Questions

Editorial Team
  • 0
Editorial Team
Asked: June 1, 20262026-06-01T16:31:52+00:00 2026-06-01T16:31:52+00:00

I am doing a quick duplicate check on a form. When comparing two strings,

  • 0

I am doing a quick duplicate check on a form. When comparing two strings, I was trying something like this:

if (stripos($_SESSION['website'], $f['website']))

I am getting this error:

Fatal error: Call to undefined function: stripos() in...

I do not want it to be an exact match, basically if the $_SESSION['website'] is http://www.google.com, I’d want stripos to return true if $f['website] is http://www.goog.com

Am I doing something wrong, or is there a better way to do this?

edit: I was doing some testing, and noticed if my $_SESSION['website'] variable contains www and .com. As does my $f['website] variable. shouldn’t strpos return that as true?

  • 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-01T16:31:53+00:00Added an answer on June 1, 2026 at 4:31 pm

    stripos(), as per the manual only exists in the core of PHP 5 or later. If stripos doesn’t exist, that would suggest you’re using PHP 4, which is wildly outdated. I suggest you upgrade. If for some insane reason you really can’t, you can always force the two strings to lowercase before calling strpos, which would have the same effect:

    <?php
    // PHP 5.
    $pos = stripos( 'www.google.com', 'google.com' );
    
    // PHP 4.
    $pos = strpos( strtolower( 'www.google.com' ), strtolower( 'google.com' ) );
    

    That said, there’s something more to your code: you’re checking if( stripos( $foo, $bar ) ) which would return 0 if the string $foo starts with the string $bar. You should check with if( stripos( $foo, $bar ) !== false ) instead.

    On another note: I don’t think stripos will help you. You mentioned www.google.com and www.goog.com, which are two totally different things. The latter is not a substring of the former, and stripos checks for the starting position of a substring, it doesn’t do “loose comparison”.

    If you want “like” and you have the terms in an array, you might want to check out the similar_text() function which will give you an indication of how similar two different strings are. As an example:

    <?php
    $similarity = 0;
    similar_text( 'www.goog.com', 'www.google.com', $similarity );
    var_dump( $similarity );
    

    The above code would set $similarity to float(92.307692307692), which is the similarity of the two strings in percentages. You can decide the threshold for the similarity yourself, naturally.

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

Sidebar

Related Questions

I often find myself doing quick checks like this: if (!eregi('.php', $fileName)) { $filename
I'm writing code like this, doing a little quick and dirty timing: var sw
This should a quick question for some easy rep. I'm doing some PHP Website
I need a quick hand figuring out what this code is doing, and how
I was just doing a quick test of something, and before I could really
I often use the python interpreter for doing quick numerical calculations and would like
After doing a quick search I can't find the answer to this seemingly simple
$('div#searchResult > div#searchResultItem > div#item').hover(function() { alert($(this).text()); }); Hi guys. Im doing a quick
I'm at a client doing some quick fixes to their access application. It was
I'm doing some real quick and dirty benchmarking on a single line of C#

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.