<html><head><style type="text/css"><!-- DIV {margin:0px;} --></style></head><body><div style="font-family:times new roman, new york, times, serif;font-size:12pt">Well, a couple of observations... You never quote any of the characters that you're assigning. I'm not sure if it's an omission or what.<br><br>Second, in the chunk of code with the ||, the first piece of code with give a a '|' for *every* character. For the second, you will get two for every character that is not M or Z and one for each M or Z.<br><br>Maybe a cut and paste of the whole code fragment might help figure out what's going on.<br><br>Cheers!<br><br>Bob<br><div> </div>--<br>"When once you have tasted flight, you will forever walk the earth with your eyes turned skyward, for there you have been, and there you will always long to return."<br> --Leonardo da Vinci<div style="font-family: times new roman,new york,times,serif; font-size: 12pt;"><br><br><div
style="font-family: times new roman,new york,times,serif; font-size: 12pt;">----- Original Message ----<br>From: Rob Dege <livemotion@gmail.com><br>To: nflug@nflug.org<br>Sent: Friday, April 18, 2008 12:22:35 PM<br>Subject: [nflug] PHP character question<br><br>
Hello to all,<br><br>I am trying to create a simple for loop, but instead of incrementing numbers, I want to increment characters. I am able to get the code to work, up until the end, when it comes time to output the last char.<br>
<br>for ($i = A; $i < Z; $i++)<br> {<br> echo "$i <br>";<br> }<br><br>In this simple example, the output would be to echo the characters A - Y, omitting Z; which is expected. If I change $i < Z to $i <= Z, one would expect to have Z included in the output. Unfortunately, this does not happen. Instead, it continues to loop past Z until it outputs YZ (A - Z, AA - AZ, BA - BZ, ..... YA - YZ). This would imply that it's matching against ZA instead of just Z. I know there are alternate ways around this, but now I'm really curious about the looping behavior here. Any insight is appreciated.<br>
<br><br clear="all">I also have a related question with an if condition, if you want further head scratching.<br><br>if ($i != M || $i != Z) { echo " | "; }<br><br>With this statement, whenever $i has the value of either M or Z it should execute the condition, but it doesn't. However, if I separate the if condition into two separate conditions statements, it works as intended.<br>
<br>if ($i != M) { echo " | "; }<br><br>if ($i != Z) { echo " | "; }<br><br>I'm not sure why the || would cause a problem, but for some reason it does.<br><br>-- <br>-Rob<br><br>Ben Franklin Quote: "They that can give up essential liberty to obtain a little temporary safety deserve neither liberty nor safety."
</div><br></div></div><br>
<hr size=1>Be a better friend, newshound, and
know-it-all with Yahoo! Mobile. <a href="http://us.rd.yahoo.com/evt=51733/*http://mobile.yahoo.com/;_ylt=Ahu06i62sR8HDtDypao8Wcj9tAcJ "> Try it now.</a></body></html>