
- PHP 7 Tutorial
- PHP 7 - Home
- PHP 7 - Introduction
- PHP 7 - Performance
- PHP 7 - Environment Setup
- PHP 7 - Scalar Type Declarations
- PHP 7 - Return Type Declarations
- PHP 7 - Null Coalescing Operator
- PHP 7 - Spaceship Operator
- PHP 7 - Constant Arrays
- PHP 7 - Anonymous Classes
- PHP 7 - Closure::call()
- PHP 7 - Filtered unserialize()
- PHP 7 - IntlChar
- PHP 7 - CSPRNG
- PHP 7 - Expectations
- PHP 7 - use Statement
- PHP 7 - Error Handling
- PHP 7 - Integer Division
- PHP 7 - Session Options
- PHP 7 - Deprecated Features
- PHP 7 - Removed Extensions & SAPIs
- PHP 7 Useful Resources
- PHP 7 - Quick Guide
- PHP 7 - Useful Resources
- PHP 7 - Discussion
How to display array values with do while or for statement in my PHP?
Following is the syntax to display array values
do{ //statement1 //statement2 . . . n } while(yourCondition);
The PHP code is as follows −
Example
<!DOCTYPE html> <html> <body> <?php $values=array('John','David','Mike','Sam','Carol'); $i=0; $len=count($values); do{ echo $values[$i]," "; $i++; } while($i<$len) ?> </body> </html>
Output
John David Mike Sam Carol
- Related Articles
- PHP How to display array values with text “even” to be displayed for even index values
- How can I count true and false values in my PHP array?
- PHP: How do I display the contents of a textfile on my page?
- Display array structure and values in PHP 7
- MySQL query to display the column and its values using OR in WHERE statement
- How do you use ‘foreach’ statement for accessing array elements in C#
- How to implement WHILE LOOP with IF STATEMENT MySQL?
- What is do...while loop statement in JavaScript?
- How to check for 'undefined' or 'null' in a JavaScript array and display only non-null values?
- How do we use continue statement in a while loop in C#?
- How do we use a break statement in while loop in C#?
- How to use PowerShell Break statement with the While Loop?
- How do I determine the size of my array in C#
- How can I write in order with for loop or while loop?
- How to remove null values with PHP?

Advertisements