Was doing some example code for a friend and I came across something very strange.

If I do:
echo "<b>" . strpos($hayStack, $num1YXX) . "=" . $hayStack . "." . $num1YXX . ",</b>";
strpos returns no value. (result is just "=000.0,").

But if I go:
Code:
echo "<b>" . strpos("000", "0") . "=" . $hayStack . "." . $num1YXX . ",</b>";
strpos returns: "0=000.0,".

Basically, it's reading the variables as empty, but they are fine when they are echoed on the same line. Anyone have any insights into this strange behavior? There's no errors.

Full code below.

Code:
<?php
error_reporting( E_ALL );
ini_set('display_errors', true); 
$num1YXX=0;   //  }
$num1XYX=0;   //   > I could have made this one array (And make able to count higher then 10 with more then 3 iterations), but did separate variables for simplicity.
$num1XXY=0;   //  }

$numberArray[]=""; //Store our awesome numbers in.
$numberCounter=0; //Keep track of how many cycles we've done (This can be calculated by the num1XXX variables).
$numPos1=false; // This is so once we've found that at least one instance of the array already exists, exit (or ignore) the rest of the loop.
$numPos2=false;
$numPos3=false;

$alreadyExists=true; //Remember if it exists or not.

for ($num1YXX=0; $num1YXX<=9; $num1YXX++)
{
  for ($num1XYX=0; $num1XYX<=9; $num1XYX++)
  {
    for ($num1XXY=0; $num1XXY<=9; $num1XXY++) // 3 indented loops, one for each integer (They are concatinated in the end).
    {
	  $alreadyExists=true;
	  $numPos1=false;
	  $numPos2=false;
	  $numPos3=false;

	  $result = $num1YXX . $num1XYX . $num1XXY;
	  foreach ($numberArray as $arrayIndex) //Check array for existing entry loop.
	  {
	    $hayStack=$arrayIndex;
	    $numPos1 = strpos($hayStack, $num1YXX);
	    $numPos2 = strpos($hayStack, $num1XYX);
	    $numPos3 = strpos($hayStack, $num1XXY);
//echo "<b>" . $numPos1 . "=" . $hayStack . "." . $num1YXX . ",</b>";
echo "<b>" . strpos($hayStack, $num1YXX) . "=" . $hayStack . "." . $num1YXX . ",</b>";
echo "<b>" . strpos("000", "0") . "=" . $hayStack . "." . $num1YXX . ",</b>";
		if ($numPos1===false && $numPos2===false && $numPos3===false)
		{
		  $alreadyExists=false;
		}
		
	  }
	  if ($alreadyExists==false)
	  {
		$numberArray[] = $result; //Add it in if it's not found.
		echo $result . "<br />"; //Also echo to screen.
	  }
	  $numberCounter++;
    }
	$numberCounter++;
  }
  $numberCounter++;
}
echo "<br /><br /> Total Unique: " . count($numberArray) . "<br />"; // Echo total amount
//echo "<br /><br /> Total Cycles: " . $numberCounter . "<br />"; // Echo cycles