How to Get Object Property Names in an Array in PHP
- 1). Click the "Start" button and select "Notepad" to open the Notepad editing software on your Windows-based computer.
- 2). Click "File", select "Open" and then double-click on the Web page file in which you want to add the function of retrieving database object property names.
- 3). Enter the following code after the "<head>" line:
<?php
$obj = new (array Product()); // declare as ArrayObject
$price = get_class_vars(get_class($obj));
foreach($prices as $price => $defaultValue)
{
$value = $obj->$price; // get the property name and its value
} - 4). Click "File' and then "Save' to apply the PHP code to the web page.
Source...