Try this:

for($x=1;$x<=512;$x++)

if(intval(sqrt($x))==sqrt(

echo "$x is a power of 2<br />";

this outputs:

1 is a power of 2

4 is a power of 2

9 is a power of 2

16 is a power of 2

25 is a power of 2

36 is a power of 2

49 is a power of 2

64 is a power of 2

81 is a power of 2

100 is a power of 2

121 is a power of 2

144 is a power of 2

169 is a power of 2

196 is a power of 2

225 is a power of 2

256 is a power of 2

289 is a power of 2

324 is a power of 2

361 is a power of 2

400 is a power of 2

441 is a power of 2

484 is a power of 2

Now if you want to know if 2^x = (array) that's a different thing altogether (this will find values like 512, 256, etc) ill get you the code in a sec