PHP 4.0 Bug #7385 Updated: 'letter counting' bug when counting a-z

From: Date: Sun, 22 Oct 2000 18:56:18 +0000
Subject: PHP 4.0 Bug #7385 Updated: 'letter counting' bug when counting a-z
Groups: php.dev 
Request: Send a blank email to php-dev+get-35807@lists.php.net to get a copy of this message
ID: 7385 User Update by: delme@jumeaux.bc.ca Status: Closed Bug Type: Scripting Engine problem Description: 'letter counting' bug when counting a-z i assume your point is that <= does not operate on letters in the same way; it's a string comparison operator. i should have seen this, i suppose. it's too late now, but perhaps php should have been developed more along the lines of perl, with separate operators for string functions... then mathematical operators could treat letters as base 26 numbers, and string operators could do alphabetical comparisons. this special overloading of ++ is misleading. Previous Comments: --------------------------------------------------------------------------- [2000-10-22 11:20:50] lyric@php.net Applying ++ to a string essentially treats it like a base-26 number. It goes from 'a,b,c... y,z,aa,ab,ac...' etc. Try something like this. Maybe some else has a tidier way? for ( $i='A'; $i!='AA'; $i++ ) print $i. '<br>'; --------------------------------------------------------------------------- [2000-10-21 21:13:14] delme@jumeaux.bc.ca for ($i = 'A'; $i <= 'Z'; $i++) { print $i. '<br>'; } the above code *should* produce 26 letters, but instead it counts all the way from A to YZ. A to ZZ counts from A to ZYZ, and so on. --------------------------------------------------------------------------- Full Bug description available at: http://bugs.php.net/?id=7385

« previous php.dev (#35807) next »