Answers for "loop through objects php"

1

php loop through object

foreach ($obj as $key => $value) {
    echo "$key => $valuen";
    //echo "test greper";
}
Posted by: Guest on May-11-2021
4

php loop object

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

    protected $protected = 'protected var';
    private   $private   = 'private var';

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

$class = new MyClass();

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


$class->iterateVisible();

?>
Posted by: Guest on February-21-2020
1

php loop through object

foreach ($obj as $key => $value) {
  echo "$valuen";
}
Posted by: Guest on October-07-2020

Code answers related to "loop through objects php"

Browse Popular Code Answers by Language