1. Home
  2. Docs
  3. PHP
  4. array object
  5. Object init and Array init

Object init and Array init

    </pre>
    <?php
    
    $object = (object) [
    'first' => 'Powen',
    'last' => 'Ko',
    ];
    
    $object->age=20;
    var_dump($object);
    print($object->first);
    
    ////////array
    $array1 = [
    'first' => 'Powen',
    'last' => 'Ko',
    ];
    $array1["age"]=20;
    var_dump($array1);
    print($array1["first"]);
    ?>
    <pre>

    output:

    object(stdClass)#1 (3) {
      ["first"]=>
      string(5) "Powen"
      ["last"]=>
      string(2) "Ko"
      ["age"]=>
      int(20)
    }
    Powenarray(3) {
      ["first"]=>
      string(5) "Powen"
      ["last"]=>
      string(2) "Ko"
      ["age"]=>
      int(20)
    }
    Powen
    
    
    <iframe src="httpsss://paiza.io/projects/e/Fcj4fw8Bi6niATTLjzMOag?theme=twilight" width="100%" height="500" scrolling="no" seamless="seamless"></iframe>