Log in

View Full Version : numerical notation oddity



james438
06-13-2010, 09:38 PM
<?php
$b="&#0";
$a=8238;
while ($a<8240)
{$b.="$a;";
echo"XX $a XX $b <br>";$b="&#";
$a++;}
?>

I would expect the output to be:


XX 8238 XX character
XX 8239 XX character
instead I get:

XX 8238 XX *
XX 8239 XX
It's best if you run the script yourself to see what I am talking about. The value for $a is strange for a while after that; a few hundred I think.

Any ideas what is going on here?

djr33
06-13-2010, 10:10 PM
There are a few reasons this is complicated:
1. The first iteration you have (for some reason I don't understand) started it with a 0.

The output that I see is:

XX 8238 XX * <br>XX 8239 XX   <br>
Or, what the browser displays:

XX 8238 XX
XX 8239 XX

Thus you are creating 08238 then 8239, not sure why.

What are these characters, and in what character encoding? You should specify unicode (I expect that's the only one that goes up that high) in your html tag, so that the page displays correctly.

HOWEVER, that generates some sort of very weird RTL character (maybe a space??) that actually completely messes up my text here if I paste it (the browser 'output' above was retyped).

fileserverdirect
06-13-2010, 10:14 PM
Try this:


<?php
$b="";
$a=8238;
while ($a<8240; $b="";)
{$b.="$a;";
echo"XX $a XX $b <br>";$b="&#";
$a++;}
?>

I don't know exactly what you are trying to do, but fiddle with the $b term in the while loop and it might work out.

james438
06-13-2010, 10:42 PM
I am not sure what these unicode characters are. Just trying to explore unicode to view all of the different dashes and hyphens that there are till I find one in a style that I like. I may have to fiddle with the font-family as well.

I fixed up the code to remove the leading 0 so it now looks like:


<?php
$a=8238;
while ($a<8240)
{$b='&#';
$b.="$a;";
echo "XX $a XX $b <br>";
$a++;}
?>

fileserverdirect, your code had a few errors in it, so I cleaned it up.

fileserverdirect
06-13-2010, 10:53 PM
Sorry, I was thinking foreach syntax whereas you can do that. So it works?

djr33
06-13-2010, 10:57 PM
There's an entire list of Unicode here:
http://www.alanwood.net/unicode/

james438
06-14-2010, 05:55 AM
fileserverdirect, not yet, but that's alright. I still get the same errors.

djr33, As simple as my script is I think I like the site you mentioned better and will be looking through that one.

thanks for the help guys :)