Home >Backend Development >PHP Tutorial >php do while loop example, phpdowhile example_PHP tutorial
do-while loop and while loop are very similar, the only difference is that do-while guarantees that it must be executed once, while while in the expression If it is not established, no operation may be performed.
The do-while loop has only one syntax:
do { statement }while (expr)
Example:
<?php $i = 1; do { echo $i; $i++; } while ($i <= 10); ?>
This example also outputs 1 to 10.
Original address: http://www.manongjc.com/php/php_while.html
php related reading:
php strlen() gets the length of the string
php strnatcasecmp() compares two strings (not case sensitive)
php strnatcmp() uses natural algorithm to compare two strings
php strpbrk() finds any one of the specified characters in the string
php strrchr() finds the last occurrence of a string in another string
php strrev() reverses the string and reverses the string