PHP 8.5.0 Alpha 2 available for testing

Voting

: min(five, seven)?
(Example: nine)

The Note You're Voting On

gfour
5 years ago
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 -

<< Back to user notes page

To Top