I am learning PHP for the first time and I find it surprising that the language allows using the increment operator on strings.
$foo = 'xyZ';
print ++$foo; // prints xzA
The tutorials I can find around this topic introduce toy examples only. I would be grateful if you mention a situation where using this 'feature' is beneficial.
Thanks in advance!
I would be grateful if you mention a situation where using this 'feature' is beneficial.
This can be a very useful feature ...
Example
$guess = "21661093e56e24cd60b10092005c4ac7";
$next = "aaaa";
$count = 0;
while(md5($next) !== $guess) {
$next ++;
$count ++;
}
printf("Found `%s` after %s loops", $next, number_format($count));
Output
Found `baba` after 17,602 loops
I don't intend to crack any PIN or password anytime soon anyway
If you love us? You can donate to us via Paypal or buy me a coffee so we can maintain and grow! Thank you!
Donate Us With