PHP Classes

File: php/accessing_object_keys_dynamically.php

Recommend this page to a friend!
  Classes of bamigboye biodun   Logical Functions   php/accessing_object_keys_dynamically.php   Download  
File: php/accessing_object_keys_dynamically.php
Role: Example script
Content type: text/plain
Description: Example script
Class: Logical Functions
General-purpose PHP and JavaScript functions
Author: By
Last change:
Date: 1 year ago
Size: 221 bytes
 

Contents

Class file image Download
<?php

$data
= (object) [
   
'name' => 'Biodun Bamigboye',
   
'gender' => 'male',
   
'skin_color' => 'Black'
];

$objectKey = 'gender';

echo
$data->{$objectKey};

// Returns male

/**
 * @author Biodun Bamigboye
 */