-3
    <?php
                if($row["lat"] > $id[$counter][2]) {
                    $lats = $row["lat"] - $id[$counter][2];
                } else {
                    $lats = $id[$counter][2] - $row["lat"];
                }
                if($row["lng"] > $id[$counter][3]) {
                    $lngs = $row["lng"] - $id[$counter][3];
                } else {
                    $lngs = $id[$counter][3] - $row["lng"];
                }
                if($lats <= 0.0003‬ && $lats >= 0) {                
                    $confirm++;
                }
                if($lngs <= 0.002 && $lngs >= 0) {
                    $confirm++;
                }
    ?>

I'm trying to take two coordinates, subtract them for each other, then check if within area. If within area, confirm for future processing. But Im getting a T_STRING error right in the section starting at the IF statement. Im almost positive this is a conversion problem.

CherryDT
  • 25,571
  • 5
  • 49
  • 74
PowerThree
  • 13
  • 5

1 Answers1

0

There is a NUL byte after 0.0003. That's a nasty invisible character.

enter image description here

To get rid of it, place the cursor to the left of the 3, press once, and then press Del. It will apparently do nothing, but this will have deleted the invisible character. Now your code should work.


To simplify this for you though, I have cleaned up this line for you (replace the line in your code with this cleaned one, copying from here):

                if($lats <= 0.0003 && $lats >= 0) {
CherryDT
  • 25,571
  • 5
  • 49
  • 74
  • That's cool, what did you use to see this? – AbraCadaver Apr 21 '20 at 21:30
  • I pasted it in https://phpcodechecker.com/, saw the error at a seemingly correct place and then looked in a hex editor (I used [HxD](https://mh-nexus.de/de/hxd/)) – CherryDT Apr 21 '20 at 21:31
  • How does this occur? – PowerThree Apr 21 '20 at 21:53
  • Very hard to say, it can come from all kinds of places depending on what you did with that code before. However my experience is that something like this happens to me maybe once a year on average in a way where I have no idea why and can't trace the source back - and if it happens to you more often you'd probably very soon identify a pattern as to what you did to get such a character introduced into your code ;) – CherryDT Apr 21 '20 at 22:51