php - Autoincrementing strings -
i'm trying build hierarquical list of categories, this:
1 category 1.1 children 1.2 children 1.2.1 children
here's code:
$a = "1.1"; echo ++$a; // 2.1 $b = "1.1.1"; echo ++$b; // 1.1.2
why $a
increments 2.1 instead of 1.2 $b
?
"1.1"
parses float value 1.1
, , can tell 1.1 + 1 = 2.1
however, "1.1.1"
can't parsed number, treated string. php supports ++
strings in different ways in attempt useful, successful letters (a
through z
, aa
, ab
...).
Comments
Post a Comment