Search
 
SCRIPT & CODE EXAMPLE
 

PHP

php counter

<?php
//counter while loop
$counter;
while($counter < 10){
	$counter++;
    echo "The number is: $counter <br>";
}
echo $counter; //returns 10

//counter for loop
$counter = 0;
for ($x = 0; $x <= 10; $x++) {
  echo "The number is: $x <br>";
  $counter = $x;
} 
echo $counter; //returns 10

//counter do while
$counter = 1;
do {
  echo "The number is: $counter <br>";
  $counter++;
} while ($counter <= 10);
echo $counter; //returns 10

//counter foreach
$colors = array("red", "green", "blue", "yellow"); 
$counter;
foreach ($colors as $value) {
  echo "$value <br>";
  $counter++;
}
echo count($cars); //returns 4
echo $counter; //returns 4
?>
Comment

php count

<?php
$comida = array('frutas' => array('naranja', 'plátano', 'manzana'),
                'verduras' => array('zanahoria', 'col', 'guisante'));

// Cuenta recursiva
echo count($comida, COUNT_RECURSIVE); // muestra 8

// Cuenta normal
echo count($comida); // muestra 2

?>
Comment

PREVIOUS NEXT
Code Example
Php :: php microtime to seconds 
Php :: Delete an array in multidimensional array php 
Php :: permissions for laravel deployment 
Php :: php creazione numero random 
Php :: php remove array element reset keys 
Php :: increase memory limit wordpress 
Php :: laravel query select from table where id != to another table id 
Php :: php split array in half 
Php :: Warning: mail(): Failed to connect to mailserver at "localhost" port 25, verify your "SMTP" and "smtp_port" setting in php.ini or use ini_set() 
Php :: E: Unable to locate package php8.0 
Php :: delete uploaded file php 
Php :: wordpress is home page 
Php :: php pdo update 
Php :: iteration in php 
Php :: laravel foreign key constraint 
Php :: php connect to mysql 
Php :: php stop execution 
Php :: skip add to cart for woocommerce 
Php :: how to get yesterday date in laravel 
Php :: laravel ckeditor 
Php :: add categories to custom post type 
Php :: laravel run migration specific file 
Php :: php previous page 
Php :: $conn-query("SET NAMES utf8"); 
Php :: how make factory and seeder in laravel 8 
Php :: php check if folder exists 
Php :: print array on php 
Php :: static modal 
Php :: string to boolean php 
Php :: create livewire component 
ADD CONTENT
Topic
Content
Source link
Name
7+4 =