note 124107 added to function.chr

From: Date: Sun, 11 Aug 2019 17:29:27 +0000
Subject: note 124107 added to function.chr
Groups: php.notes 
Request: Send a blank email to php-notes+get-211879@lists.php.net to get a copy of this message
I was looking for a simple method to construct excel like column identifiers e.g: A B .... AA AB AC etc, using chr() and modulo, but there is magic... https://www.php.net/manual/en/language.operators.increment.php So, this also works <?php $p = chr(65); // or simply $p = 'A'; for ($i = 1; $i < 53; $i++){ echo $p++ . " - "; if ($i % 10 == 0) echo '</br>'; } ?> Gives A - B - C - D - E - F - G - H - I - J - K - L - M - N - O - P - Q - R - S - T - U - V - W - X - Y - Z - AA - AB - AC - AD - AE - AF - AG - AH - AI - AJ - AK - AL - AM - AN - AO - AP - AQ - AR - AS - AT - AU - AV - AW - AX - AY - AZ - ---- Server IP: 208.43.231.9 Probable Submitter: 185.85.3.168 (proxied: 193.92.190.42) ---- Manual Page -- http://php.net/manual/en/function.chr.php Edit -- https://master.php.net/note/edit/124107 Del: integrated -- https://master.php.net/note/delete/124107/integrated Del: useless -- https://master.php.net/note/delete/124107/useless Del: bad code -- https://master.php.net/note/delete/124107/bad+code Del: spam -- https://master.php.net/note/delete/124107/spam Del: non-english -- https://master.php.net/note/delete/124107/non-english Del: in docs -- https://master.php.net/note/delete/124107/in+docs Del: other reasons-- https://master.php.net/note/delete/124107 Reject -- https://master.php.net/note/reject/124107 Search -- https://master.php.net/manage/user-notes.php

« previous php.notes (#211879) next »