Problem in string functions

consider the following line


the value of $a is available in my program after execution.
i have to check whether the value of $a is available.For that i have used the following lines.

if ($a==$aa)
echo “same”;
echo “not same”;

i am getting result as “not same”.why?

Are you sure? What value does $pos have?

Try echoing the value of $a:

echo "a: '$a'<br/>";

The value of pos is a number.I have printed $a.The value is “available”.

No it isn’t. Your script would display ‘same’.

Try echoing $a with the code I posted. Copy & paste the result here. Including the single quotes (') !

Here is my code.I have attached a text file from which i read.
$myfile = “whois.txt”;
$handle = fopen($myfile, “r”);
$contents = fread($handle, filesize($myfile));

$word=“appears to be”;


echo “a=”.$a;
echo “<br>”;
echo “aa=”.$aa;
echo “<br>”;

if ($a==$aa)
echo “same”;
echo"not same";

Please do the echo like this:

echo "a: '$a' <br />";

The single quotes are important. They’ll show you if there is a space after ‘available’ (because ‘available’ is 9 characters, and you are taking 10 with the substr() ).

Here is the result

a:’ available’
not same

Do you see the space in front of available?
’ available’ is not the same as

I am so sorry.I missed to watch that.Thank you very much.