I am simulating an address comparison that will determine the difference of a user's input to a google map api output. Let's say that $str1=is the user input and $str2=is the google output.
I use the split to break the strings into arrays and
strcasecmp to compare them. My question is how to compare all the array values that are split, currently it only compares 199a and 199 in this part.
$var = strcasecmp($strarr[0], $strarr2[0]);
Update...........
<?php
$str1 = "199a Freestone Road, Sladevale QLD 4370, Australia";
$str2 = "199 Freestone Road, Sladevale QLD 4370, Australia";
$strarr = (explode(" ",$str1));
echo("<br>");
$strarr2 = (explode(" ",$str2));
echo("<br>");
$var = strcasecmp($strarr[0], $strarr2[0]);
echo"$var";
if($var===0)
{
echo("The Strings are equal.");
}
elseif ($var==!0)
{
echo("<br>");
echo("wafasd");
}
I appreciate all your suggestions on just directly compare the two arrays,yes it may solve the current comparison problem, but due to some parts of the current project I am working on I am not sure if it is suited. I'll elaborate it below
User's Input: 199a Sladevale Road, Sladevale QLD 4370, Australia
Google Map API Output: 199 Freestone Road, Sladevale QLD 4370, Australia
Changes(this is what I am trying to achieve):
199a is changed by Google into 199
Sladevale is changed by Google into Freestone