Business
Jobs
  • About Us
  • Solutions
    • Job Postings
      Post your job and receive qualified candidates in 48h.
    • Candidate Assessments
      500+ technical and psychological tests, plus anti-fraud.
    • Headhunting
      Tailor-made executive search from start to finish.
    • Payroll + EOR
      Payroll dispersal and EOR across 15+ LATAM countries.
  • Pricing
  • Jobs

0

183
Views
How to do match exactly the content using PHP?

I need to match two string using PHP. Here is my code:

<?php

$fistno="9937229853";
$secondno="+919937229853";

?>

Here I need the value in $fistno is present in $secondno or not. If the value in $fistno is present in $secondno it will return true. In this case 9937229853 is present in $secondno so it should return true.

over 4 years ago · Santiago Trujillo
3 answers
Answer question

0

Use strpos, see here.

if (strpos($mystring, $findme) === false) {

    return false;
}

return true;

Be careful and use === false as the string position in the other string can be 0 which when using == will evaluate to false when it is actually true.

over 4 years ago · Santiago Trujillo Report

0

Use strpos

if (strpos($fistno, $secondno) !== false) {
    echo 'true';
}
over 4 years ago · Santiago Trujillo Report

0

You need to use == not just =

$check = 'this is a string 111';
if (strpos($mystring, $findme) === false) {
    echo 'perfect match';
} 
else {
    echo 'it did not match up';
}

= will assign the variable.
== will do a loose comparison.
=== will do a strict comparison.

over 4 years ago · Santiago Trujillo Report
Answer question
Find remote jobs

Discover the new way to find a job!

Top jobs
Top job categories
Business
Post vacancy Pricing Sales
Legal
Terms and conditions Privacy policy
© 2026 PeakU Inc. All Rights Reserved.
Andres GPT
Show me some job opportunities
There's an error!