Horje
php loop through obect Code Example
php loop through obect
PHP By Wandering Weevil on Mar 8 2020
$person = new StdClass();
$person->name = "Ngbokoli";
$person->age = 31;
$person->nationnality = "Congolese";
$person->profession = "Student";

foreach ($person as $key => $value) {
    echo $key." ".$value."\n";
}
loop through object php

<?php
class MyClass 
{
  public $var1 = 'valeur 1';
  public $var2 = 'valeur 2';
  public $var3 = 'valeur 3';

  protected $protected = 'variable protégée';
  private   $private   = 'variable privée';

  function iterateVisible() {
     echo "MyClass::iterateVisible:\n";
     foreach ($this as $key => $value) {
         print "$key => $value\n";
     }
  }
}

$class = new MyClass();

foreach($class as $key => $value) {
    print "$key => $value\n";
}
echo "\n";


$class->iterateVisible();

Source: www.php.net




Php

Related
php loop through objects Code Example php loop through objects Code Example
Using the PHPExcel library to read an Excel file and transfer the data into a database Code Example Using the PHPExcel library to read an Excel file and transfer the data into a database Code Example
livewire pagination bootstrap Code Example livewire pagination bootstrap Code Example
get time ISO 8601 wordpress Code Example get time ISO 8601 wordpress Code Example
SELECT query with PDO Code Example SELECT query with PDO Code Example

Type:
Code Example
Category:
Coding
Sub Category:
Code Example
Uploaded by:
Admin
Views:
11